Hellbringer2572 Posted April 30, 2010 Share Posted April 30, 2010 I need some help with regular expression. i am working on a mod to go though posts that are on my site to see if people are posting email address is the post as advertising so i want to search a string for a email address. i have this.. $pattern = '/@.*/'; preg_match_all($pattern, $post, $matches); seeing that the @ symbol breaks it up and makes it think it is 3 different words how do i write the regular expression to grab the portion before the @ and the portion behind the @ and stop at the end of the .com (when i ran that code i get this..... [0] => @HOTMAIL.COM">testemail@HOTMAIL.COM or testemail2@HOTMAIL.COM which is two emails posted next to each other i just want to get the testemail@hotmail.com) Thanks Mike Quote Link to comment https://forums.phpfreaks.com/topic/200253-regular-expression-help/ Share on other sites More sharing options...
Adam Posted April 30, 2010 Share Posted April 30, 2010 Your expression isn't specific enough. Quite often people put something like "@someuser ..." to address someone specifically, but your expression would match this too. You'll easily be able to find a decent regexp to match email addresses on the internet, and you can just modify that to also 'backreference' the parts of the string you need. http://www.regular-expressions.info/brackets.html Quote Link to comment https://forums.phpfreaks.com/topic/200253-regular-expression-help/#findComment-1050899 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.