473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

reg expression help needed

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:fr**@blah.com"> emal me</a> woud be matched as expected, but
so will:

<a href="mailto:fr**@blah.com"> 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!

Sep 24 '05 #1
1 1947
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" <as**@sdarta.com>
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: <43***********************@per-qv1-newsreader-01.iinet.net.au>
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!newsfee d00.sul.t-online.de!t-onli
ne.de!news.glorb.com!nntp.waia.asn.au!203.59.27.18 6.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-mailXref: 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:fr**@blah.com"> emal me</a> woud be matched as expected, butso will:

<a href="mailto:fr**@blah.com"> 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: sd*****@microsoft.com\par
\f1\par
}

Sep 26 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Tina Li | last post by:
Hello, I've been struggling with a regular expression for parsing XML files, which keeps giving the run time error "maximum recursion limit exceeded". Here is the pattern string: ...
23
by: Paul Rubin | last post by:
OK, I want to scan a file for lines matching a certain regexp. I'd like to use an assignment expression, like for line in file: if (g := re.match(pat, line)): croggle(g.group(1)) Since...
4
by: pekka niiranen | last post by:
Hi there, I have perl script that uses dynamically constructed regular in this way: ------perl code starts ---- $result ""; $key = AAA\?01; $key = quotemeta $key; $line = " ...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
13
by: Zeng | last post by:
Hello, Please help!!! I've been stuck on this issue for months. I just wonder if there is a way to programmatically evaluate expression strings such as ( ( 3 + 5 ) / 2 ) > 4 --> this...
2
by: Kjetil Klaussen | last post by:
Hi, I’m having some troubles trying to bind my dataset to a GridView control through an ObjectDataSource control. The binding works fine for regular columns in my dataset, but I can’t seem...
1
by: Jan Limpens | last post by:
Hello, I am creating a simple CRUD application which uses xml files as data storage. I extended Textbox with a XPath expression and a XmlDocument property, this way I can easily read and update...
9
by: Earl | last post by:
I have somewhat of an interesting scenario: The form allows the user to select a service, which populates a a grid of product information related to that service ("service grid"). The user can...
28
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to...
8
by: PJ6 | last post by:
Const factor As Double = Math.Sqrt(3) / 6 Error 1 Constant expression is required. This looks like laziness to me. In SQL Server, functions are given a distinction between ones that always...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.