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 cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

regexp

Status
Not open for further replies.

devoeger

New member
Joined
Jul 28, 2006
Messages
1
Location
US
I'm new to Reg Expressions and VB script, but after doing some seaches, I found that the following works well to return the first value...

Set re = New RegExp
With re
.Pattern = "\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b"
.IgnoreCase = True
.Global = True
End With
Set matches = re.Execute(htmlResult)
getadd = matches.item(0).value
msgbox getadd

If I change getadd to...
getadd = matches.item(0).value + ", " + matches.item(1).value
I can get the first 2 values. The problem is I want all of the values (the total number will vary) in the single variable getadd (I want to return all of the matches in a single message box). Any help?
 
If you use something like:
Code:
'loop through all elements of matches
for each m in matches
    getadd = getadd + m.value + ","
next m
'strip the last comma
getadd = left(getadd, len(getadd)-1)


Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top