joshis Posted January 17, 2011 Share Posted January 17, 2011 Hellom I have a text string. That may or maynot contain email addresses. I want to replace all . (fullstop) to dot. I mean blah blah [email protected] fooo to blah blah abcd@gmail dot com fooo Can I do with regex rules? -Thanks Link to comment https://forums.phpfreaks.com/topic/224721-replace-from-email-address/ Share on other sites More sharing options...
JAY6390 Posted January 17, 2011 Share Posted January 17, 2011 $text = preg_replace('/\b([A-Z0-9._%+-]+@[A-Z0-9.-]+)(\.)([A-Z]{2,4}\b)/i', '$1 dot $3', $$text); Link to comment https://forums.phpfreaks.com/topic/224721-replace-from-email-address/#findComment-1160691 Share on other sites More sharing options...
joshis Posted January 17, 2011 Author Share Posted January 17, 2011 Wow, Its worked. 1000000000 Thanks Jay... -Arun Link to comment https://forums.phpfreaks.com/topic/224721-replace-from-email-address/#findComment-1160694 Share on other sites More sharing options...
JAY6390 Posted January 17, 2011 Share Posted January 17, 2011 No problem Link to comment https://forums.phpfreaks.com/topic/224721-replace-from-email-address/#findComment-1160698 Share on other sites More sharing options...
JAY6390 Posted January 17, 2011 Share Posted January 17, 2011 Also note the $$text should be $text (ie the two $$ was a typo) - I tried to edit but the time limit expired apparently, so hopefully you don't have the same as me if it's working Link to comment https://forums.phpfreaks.com/topic/224721-replace-from-email-address/#findComment-1160701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.