tags:

views:

12

answers:

2

I need to search for filename AM*GQ, where * is sequence eg 344

Can i do this vbs?

Thanks in advace!!

A: 

you can use instr()

ghostdog74
A: 

Regular Expressions should work.

pattern = "[A][M][0-9]*[C][Q].*"
string = "AM432CQ.txt"
MsgBox RegExTest(pattern,string)

Function RegExTest(pattern, strng)
   Dim regEx, Match, Matches   ' Create variable.
   Set regEx = New RegExp   ' Create a regular expression.
   regEx.Pattern = pattern   ' Set pattern.
   regEx.IgnoreCase = True   ' Set case insensitivity.
   regEx.Global = True   ' Set global applicability.
   Set Matches = regEx.Execute(strng)   ' Execute search.
   For Each Match in Matches   ' Iterate Matches collection.
      RetStr = RetStr & "Match found at position "
      RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
      RetStr = RetStr & Match.Value & "'." & vbCRLF
   Next
   RegExTest = RetStr
End Function
Tester101
Thanks a lot!!!!!
Min