Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • 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
Jul 28, 2006
1
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?
 
Replies continue below

Recommended for you

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