PHP regex performed in a specific order -
i have bunch of email addresses so
smtp:nickp@office.email.com smtp:nick@mailtrack.com smtp:nick.p@email.com smtp:nick@email.com smtp:nicholas@email.com i need think requires done in specific order. basically, firstly need check smtp because although dont show above, there bad rows in data. need emails solely end in email.com.
really, think need line capital smtp first. output looking this
nick: nick@relay.email.com nick.p: nick@relay.email.com nicholas: nick@relay.email.com maybe understand better
$email_prefix_from_smtp: email_prefix_from_smtp@relay.email.com $email_prefix_from_smtp: email_prefix_from_smtp@relay.email.com $email_prefix_from_smtp: email_prefix_from_smtp@relay.email.com so emails same, , thats prefix capital smtp + relay.email.com.
the information before colon email prefix individual smtp. have @ moment this
if(preg_match_all('/smtp:(.*?@email\.com)$/im', $email, $matches)) { foreach($matches[1] $match) { $emailprefix = substr($match, 0, strpos($match, '@')); print_r($emailprefix . ": " . $emailprefix . "@relay.email.com" . "<br>"); } } that gives me correct data before colon, email addresses not same.
how can output data in way have described?
thanks
why search prefix later? can split directly in parts:
$email = "smtp:nickp@office.email.com smtp:nick@mailtrack.com smtp:nick.p@email.com smtp: nick@email.com smtp:nicholas@email.com"; preg_match_all("/^(.+):\s*(\s*)@(email\.com)$/igm", $email, $matches); foreach($matches $match) { print_r($match[1] . ": " . $match[2] . "@relay.email.com" . "<br>"); } please note haven't tested code now... regex should work, idea of rest.
Comments
Post a Comment