Skip to content

Instantly share code, notes, and snippets.

@taka2
Created April 12, 2010 14:35
Show Gist options
  • Select an option

  • Save taka2/363621 to your computer and use it in GitHub Desktop.

Select an option

Save taka2/363621 to your computer and use it in GitHub Desktop.
Set regex = New RegExp
regex.Pattern = "\[[^\[\]]*\]"
regex.Global = True
Set dict = CreateObject("Scripting.Dictionary")
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(WScript.Arguments(0))
While ts.AtEndOfStream = False
lineData = ts.ReadLine()
If Left(lineData, 2) = "*p" Then
Set matches = regex.Execute(lineData)
For Each match In matches
If dict.Exists(match.Value) Then
dict(match.Value) = dict(match.Value) + 1
Else
dict.Add match.Value, 1
End If
Next
End If
Wend
ts.Close()
For Each key In dict.Keys
value = dict(key)
If value > 1 Then
WScript.Echo key & " = " & value
End If
Next
msgbox "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment