regex - PHP preg_match result -


this php function working fine:

if (preg_match ("/<(\s+@\s+\w)>.*\n?.*55[0-9]/i",$body,$match)) { echo "found!"; } 

in

this message created automatically mail delivery software.  message sent not delivered 1 or more of recipients. permanent error. following address(es) failed:  xxx@hotmail.com smtp error remote mail server after rcpt to:<xxx@hotmail.com>: host mx3.hotmail.com [65.54.188.72]: 550 requested action not taken: mailbox unavailable 

but if use same php function in case:

a message sent not delivered 1 or more of  recipients. permanent error. following address(es) failed:  xxx@yahoo.com smtp error remote mail server after end of data: host d.mx.mail.yahoo.com [209.191.88.254]: 554 delivery error: dd user doesn't have yahoo.com account (xxxd@yahoo.com) [0] -  mta1010.mail.mud.yahoo.com 

the preg_match function not give results. doing wrong?

you looking email addressing enclosed in < , >.

your first input has second input not: has no email id in < > hence don't match.

edit: (after comment):

looking @ 2 samples given email id appears between string failed: , error code starting 55. can make use of preg_match as:

if(preg_match('/failed:.*?(\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}\b).*55[\d]/is',$str,$m)) {        echo "bounced email ".$m[1]."\n"; } 

ideone link


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -