Home > front end >  VBS script statistical certain words appear in the TXT file
VBS script statistical certain words appear in the TXT file

Time:12-09

Use the VBS script statistical certain words appear in the TXT file number and output

CodePudding user response:

Use the RegExp + Dictionary to solve;

CodePudding user response:

On the second floor, regular expressions, and dictionary is ok,
Specific code is as follows, for example, I find the string of three consecutive Numbers, and then into an array, the array is the number of the number,
 
STR="test data including 123, see can find 234 out of the 456 words in 777 continued three Numbers!"

The Pattern="\ d {3}"
MsgBox (STR)
MSG=RegExpGeneral (STR, Pattern)



For Each I In MSG
If IsEmpty (I) Then
The Exit For
End the If
MsgBox I
Next


The Function RegExpGeneral (TextValue, Pattern)
Dim I
The Set RegExpGen=New RegExp
With RegExpGen
The Global=True
'set the Global applicability
The IgnoreCase=True
'set the instance of insensitivity
. The Pattern Pattern of=
'mode
The Set Matches=. The Execute (TextValue)
'executive search regular that formed the array object
End With
'definition of a dynamic array to determine the length of the returned result
Dim MyArraysLenth
ReDim MyArraysLenth (Matches. Count)
For I=0 To Matches. Count - 1
MyArraysLenth (I)=Matches (I). The Value
Next
RegExpGeneral=MyArraysLenth
End the Function


CodePudding user response:

Thank you thank you, the problem has been resolved
  • Related