Friday, 29 October 2010

RegularExpression Testing

'RegularExpression Testing

Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
For Each Match in Matches ' Iterate Matches collection.
RetStr = RetStr & Match.Value' & vbCRLF
Next
RegExpTest = RetStr
End Function

a=(RegExpTest("[a-z]", "wipro123xyz45"))

'Regular expression for date formate (mm/dd/yy)
[1-9]|1[0-2]/[1-9]|[1-2][0-9]|3[0-1]/[0-9][0-9] ------12/10/99

"|" Indicates a choice between two items.

No comments:

Post a Comment