Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegExp in ASP

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I use regexpressions in ASP. It's a bit complicated for me and maybe you can help me to find the solution :

I've this expression : "[firstname] [last name]"
and I'd like to get following sub matches :
- "firstname"
- " "
- "last name"

For the moment, I use this pattern :

"\[([^\]]*)\]([^\[]*)"

but I only get "firstname" and " "

I would be thankfull if you find the answer
 
Hello, Midjoule.

Do not get the reason why you want to match the space. But, here is a simple solution to match firstname and lastname.

Option Explicit
Dim oRE, Matches, fedstring
Set oRE = New oRE
fedstring = "[Mid] [Joule]" 'testing only
oRE.Pattern = "\[([^\]]*)\]"
oRE.Global = True
Set Matches = oRE.Execute(fedstring)
WScript.Echo "FirstName : " & Matches(0).Submatches(0)
WScript.Echo "LastName : " & Matches(1).Submatches(0)
Set Matches = Nothing
Set oRE = Nothing

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top