reg expression help needed

  • Thread starter Thread starter worzel
  • Start date Start date
W

worzel

Hi All,

I am looking for a reg ex that will match email addresses withing <a
href=mailto blah > links.

Actually, I already crafted my own, but with a slight problem:

<a href="mailto:[email protected]"> emal me</a> woud be matched as expected, but
so will:

<a href="mailto:[email protected]"> emal me</a></td></tr> (table code also
captured)

I think this has something to do with greediness?

Any help much appreciated. As would a link to a site with tons of pre
crafted reg exs!
 
Worzel,

This regex will capture the email address from the href only:


public static Regex regex = new Regex(
@"([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\."
+ @")|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})",
RegexOptions.IgnoreCase
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled
);

This is rather standard:
([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-
]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})

Please get back to me and tell how it works for you.

Thanks,
--------------------
From: "worzel" <[email protected]>
Newsgroups: microsoft.public.dotnet.general
Subject: reg expression help needed
Date: Sat, 24 Sep 2005 10:15:08 +0800
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Lines: 20
Message-ID: <[email protected]>
NNTP-Posting-Host: 203.59.171.132
X-Trace: 1127528106 per-qv1-newsreader-01.iinet.net.au 25159 203.59.171.132
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli
ne.de!news.glorb.com!nntp.waia.asn.au!203.59.27.186.MISMATCH!newsfeed.iinet.
net.au!newsfeed.iinet.net.au!per-qv1-newsstorage1.iinet.net.au!per-qv1-newss
torage1.iinet.net.au!per-qv1-newsreader-01.iinet.net.au!not-for-mail
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.general:50595
X-Tomcat-NG: microsoft.public.dotnet.general

Hi All,

I am looking for a reg ex that will match email addresses withing <a
href=mailto blah > links.

Actually, I already crafted my own, but with a slight problem:

<a href="mailto:[email protected]"> emal me</a> woud be matched as expected, but
so will:

<a href="mailto:[email protected]"> emal me</a></td></tr> (table code also
captured)

I think this has something to do with greediness?

Any help much appreciated. As would a link to a site with tons of pre
crafted reg exs!

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fprq2\fcharset0
MS Sans Serif;}{\f1\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.21.2500;}\viewkind4\uc1\pard\f0\fs20 Cheers,\par
\par
johnKn [MS-SDK]\par
\par
\par
\par
-Please do not send email directly to this alias. This alias is for \par
newsgroup purposes only\par
\par
-This posting is provided "AS IS" with no warranties, and confers no
rights.\par
\par
-To provide additional feedback about your community experience please send
\par
e-mail to: (e-mail address removed)\par
\f1\par
}
 
Back
Top