LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-14-2009, 03:37 AM   #1
sriphp
Member
 
Registered: Apr 2009
Posts: 48

Rep: Reputation: 15
extracting emails from file using regular expressions in php on linux


hai all,

i am trying to get emails from external file.

i get file contants in a string called $contants.

i am using preg_match_all('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/',$contents, $matches);

but i am not getting emails.

please tell the actual patern for this.

thanks
Sri.
 
Old 09-14-2009, 04:02 AM   #2
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by sriphp View Post
hai all,

i am trying to get emails from external file.

i get file contants in a string called $contants.

i am using preg_match_all('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/',$contents, $matches);

but i am not getting emails.

please tell the actual patern for this.

thanks
Sri.
We would be happy to provide an actual pattern regex, but to do this, we need the actual pattern to be searched for, e.g. the layout of the data in the file -- not all "external files" have the same internal formatting.
 
Old 09-14-2009, 04:18 AM   #3
sriphp
Member
 
Registered: Apr 2009
Posts: 48

Original Poster
Rep: Reputation: 15
reply extracting emails from file using regular expressions in php on linux

hai,

in my file i have only text like

some abc text testcode abc@asd.com sample text ddd@qqq.com zzzz gggg hgh@ax.co.in
some abc text testcode abc@asd.co.in sample text eed@qse.com zzzz gggg qwh@asx.co.in dfgdfg dfgdfg
fgdfgdfgd

i wANT ONLY EMAILS TO EXTRACT.

please telme reg ex pattern for this

thanks
Sri.
 
Old 09-14-2009, 04:34 AM   #4
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by sriphp View Post
hai,

in my file i have only text like

some abc text testcode abc@asd.com sample text ddd@qqq.com zzzz gggg hgh@ax.co.in
some abc text testcode abc@asd.co.in sample text eed@qse.com zzzz gggg qwh@asx.co.in dfgdfg dfgdfg
fgdfgdfgd

i wANT ONLY EMAILS TO EXTRACT.

please telme reg ex pattern for this

thanks
Sri.
There must be more to the internal formatting than this, unless by "i wANT ONLY EMAILS TO EXTRACT" you mean you only want e-mail addresses, not complete e-mails.

There are many examples of e-mail address filters posted on the internet:

http://www.google.com/#&q=email+address+filter+regex
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] BBCode replacement technique in PHP - using regular expressions vharishankar Programming 12 07-13-2009 01:15 AM
LXer: Applied regular expressions in PHP: Provisioning the Linksys PAP2T LXer Syndicated Linux News 0 10-24-2008 04:40 PM
regular expressions in php ALInux Programming 4 11-07-2005 12:48 PM
Php and regular expressions logicdisaster Programming 9 06-26-2004 06:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration