schilly Posted April 14, 2010 Share Posted April 14, 2010 I'm working on bounce processing and I need some trying to get the bounce error message. My pattern matching is terrible so I need some help with what should be a simple pattern. Here is an example bounce message body: Hi. This is the qmail-send program at yyyyy.xxxx.com. I'm afraid I wasn't able to deliver your message to the following addresses. This is a permanent error; I've given up. Sorry it didn't work out. <email_address>: Connected to ip_address but sender was rejected. Remote host said: 550 SC-001 Mail rejected by Windows Live Hotmail for policy reasons. Reasons for rejection may be related to content with spam-like characteristics or IP/domain reputation problems. If you are not an email/network admin please contact your E-mail/Internet Service Provider for help. Email/network admins, please visit http://postmaster.live.com for email delivery information and support --- Below this line is a copy of the message. ... etc ... I basically need everything in between "<email_address>:" and "--- Below this line is a copy of the message." I tried: eregi("^<email_address>*.)--- Below this line is a copy of the message.$",$body,$matches); But I was keep getting this error: Warning: eregi() [function.eregi]: REG_BADRPT I assuming because my pattern is bad. Any help is appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/198561-find-string-between-two-strings-pattern-help/ Share on other sites More sharing options...
schilly Posted April 14, 2010 Author Share Posted April 14, 2010 also, would this way be faster than doing it via strpos? Quote Link to comment https://forums.phpfreaks.com/topic/198561-find-string-between-two-strings-pattern-help/#findComment-1041980 Share on other sites More sharing options...
newbtophp Posted April 14, 2010 Share Posted April 14, 2010 Eregi is deprecated, use preg_match and add delimiters to the start and end of your expression. Furthermore the problem is your adding ^ and $, which woul'dnt work as its not the start and end of the string your trying to match (in this case $body) Also escape the dot and dashes as they are considered special characters in regex. Try the following: preg_match("~<email_address>.*)\-\-\- Below this line is a copy of the message\.~Us",$body,$matches); Quote Link to comment https://forums.phpfreaks.com/topic/198561-find-string-between-two-strings-pattern-help/#findComment-1042000 Share on other sites More sharing options...
schilly Posted April 14, 2010 Author Share Posted April 14, 2010 awesome. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/198561-find-string-between-two-strings-pattern-help/#findComment-1042007 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.