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 abcd@gmail.com fooo to blah blah abcd@gmail dot com fooo Can I do with regex rules? -Thanks Quote 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); Quote 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 Quote 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 Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/224721-replace-from-email-address/#findComment-1160701 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.