By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

reg exp.

P: n/a
Hi all
I want to extract the email from lines, which reg exp. function i
should call?
thanks
from Peter (cm****@hotmail.com)
Aug 26 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
you use the strstr function in php.

damu
http://youropensource.com/
Aug 26 '08 #2

P: n/a
On Aug 26, 9:09*am, Damodhar <damu...@gmail.comwrote:
you use the strstr function in php.

damuhttp://youropensource.com/
You can also use preg_match
virtuPIC

--
Airspace V - international hangar flying!
http://www.airspace-v.com/ggadgets for tools & toys
Aug 26 '08 #3

P: n/a
On 26 Aug, 10:53, virtuPIC <WebMas...@airspace-v.comwrote:
On Aug 26, 9:09 am, Damodhar <damu...@gmail.comwrote:
you use the strstr function in php.
damuhttp://youropensource.com/

You can also use preg_match
virtuPIC

--
Airspace V - international hangar flying!http://www.airspace-v.com/ggadgetsfor tools & toys
You want an email address - but what do you mean by an email address?

us**@example.com
user.example.com.
"Some Guy" <us**@example.com>
hosta!hostb.edu!somewhere.else.com!example.com!use r
us**@example.com, ot***@example.com
"internal@accounts receivable"@example.com
CN=A User/OU=accounts/DC=com/DC=example

Each line above is a valid email address.

This might be what you are looking for:
/(\b)([a-z0-9\._%+!$&*=^|~#%'`?{}/\-]+@([a-z0-9\-]+\.){1,}([a-z]{2,6}))
(\b)/i

C.
Aug 26 '08 #4

P: n/a
C. (http://symcbean.blogspot.com/) wrote:
On 26 Aug, 10:53, virtuPIC <WebMas...@airspace-v.comwrote:
>On Aug 26, 9:09 am, Damodhar <damu...@gmail.comwrote:
>>you use the strstr function in php.
damuhttp://youropensource.com/
You can also use preg_match
virtuPIC

--
Airspace V - international hangar flying!http://www.airspace-v.com/ggadgetsfor tools & toys

You want an email address - but what do you mean by an email address?

us**@example.com
user.example.com.
"Some Guy" <us**@example.com>
hosta!hostb.edu!somewhere.else.com!example.com!use r
us**@example.com, ot***@example.com
"internal@accounts receivable"@example.com
CN=A User/OU=accounts/DC=com/DC=example

Each line above is a valid email address.

This might be what you are looking for:
/(\b)
[snip]

First off, you capture the word boundaries, which are zero-width
assertions, so will never match anything.
([a-z0-9\._%+!$&*=^|~#%'`?{}/\-]+
[snip]

Also, it's better to use the pre-defined character class \w, rather
than checking for [a-z0-9_] manually. \w is locale-specific, and may
match other valid characters. You also don't need to escape dots in
character classes.
@([a-z0-9\-]+\.){1,}([a-z]{2,6}))(\b)/i
You also use {1,} when the + quantifier would do.

@OP: Anyway, there are people who've made enormous regexes according
to the RFC, although it isn't always necessary to go to such lengths
to validate an email.

--
Curtis
Aug 26 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.