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

RegEx to extract part of email srting

Status
Not open for further replies.

cluM09

Technical User
May 15, 2004
127
US
Hello,

I need help with the RegEx pattern to extract part of the email string to get just a part of the domain.

For example, I need to parse only for the word ntdomain from the string below:

Username@ntdomain.abc.int.com

What will be the pattern for the regEX?

Thanks.



 
Have you looked at the WSH documentation for regular expressions? Taking apart an email address is actually one of the examples in the docs.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thanks EbGreen.

I downloaded the WSH doumentation (script56.chm) , but IE 7 won't be able to open it. How can I open it?

Any ideas?

 
Code:
Option Explicit

Dim RegEx : Set RegEx = New RegExp
RegEx.Pattern = "@(\w+)\."
RegEx.Global = True
RegEx.IgnoreCase = True
Dim strTemp : strTemp = "Username@ntdomain.abc.int.com"
WScript.Echo RegEx.Execute(strTemp)(0).SubMatches(0)

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top