[thelist] Regular expression

Gary McPherson lists at ingenyus.net
Wed Jan 28 17:40:42 CST 2004

Mark Joslyn wrote:

>I need an ASP regular expression that takes the following:
>xxx at zzzzzzzzz.com
>And gives me everything between the @ and the .
>Any help would be appreciated. I am having a very hard time learning
>reg. Expressions. Would appreciate some good links to look at to learn
>these beasts!
How does this work for you?

Not sure if you only wanted the expression itself or the code to go with 
it, but just in case, you'd use something like:
dim strSearch
dim objRegExp
dim colMatches
dim objMatch

Set objRegExp = new regexp
strSearch = "test at address.com"

objRegExp.pattern = "\w+@(\w+)\..+"
objRegExp.ignorecase = True

Set colMatches = objRegExp.Execute(strSearch)
for each objMatch in colMatches
'do your thing here

Set colMatches = nothing
Set objMatch = nothing

Haven't tested it in ASP myself, but I think it should do the trick for 
you with a little tweaking at most. However, you may find it doesn't do 
what you want with certain addresses - matching thelist at lists.evolt.org, 
for example, would return "lists". You'll need to think carefully about 
how to handle the differing formats that email addresses may be 
presented in.

As for further resources, you could look at 
http://sitescooper.org/tao_regexps.html for explanations of regular 
expressions and perhaps 
http://www.ilovejackdaniels.com/ASP/VBScript_Regular_Expressions for 
examples of how to use them in ASP.

Hope that helps,


More information about the thelist mailing list