VBScript + Regular Expressions
- by Karthik
Dim sString
sString = "John;Mary;Anne;Adam;Bill;Ester"
Is there a regex I can use to retrieve the following from the above list:
John (; at the end of the name)
Anne (; at the beginning and end)
Ester (; at the beginning)
I am currently using the following regex for each:
1. Joh.*
2. .*An.*
3. .*st.*
But, the above retrieves the entire string instead of the values I want. How can I get the correct values?
Code:
Dim oRegex : Set oRegex = New RegExp
oRegex.Global = False
oRegex.IgnoreCase = False
'John
oRegex.Pattern = "Joh.*"
Set oMatch = oRegex.Execute(sString)
sName = oMatch(0)
The above code retrieves the entire string, instead of only John. Same issue with the others :(