blackcell Posted July 13, 2012 Share Posted July 13, 2012 Hello guys(and girls), I am finding more of a need to learn RegEx. I have a very basic knowledge of it(basically what it is used for and how to make literal text matches with no considerations. I have been trying to figure out how to go about writing a regex to block emails originating from anyone@domain.in but I don't want to block jim.inners@somewhere.com What do I use to restrict the match to must not have anything following it? Quote Link to comment https://forums.phpfreaks.com/topic/265621-regex-for-to-block-emails-from-in/ Share on other sites More sharing options...
ignace Posted July 13, 2012 Share Posted July 13, 2012 No need for regex: if (substr(trim($email), -3) === '.in') { // we got a problem! } Regex would be: if (preg_match('!\.in$!', $email)) { // we got more problems here! } Quote Link to comment https://forums.phpfreaks.com/topic/265621-regex-for-to-block-emails-from-in/#findComment-1361302 Share on other sites More sharing options...
blackcell Posted July 13, 2012 Author Share Posted July 13, 2012 Thanks a ton! This is an expression match on an exchange server. So the backslash wasn't accepted for some weird reason. Quote Link to comment https://forums.phpfreaks.com/topic/265621-regex-for-to-block-emails-from-in/#findComment-1361311 Share on other sites More sharing options...
ignace Posted July 13, 2012 Share Posted July 13, 2012 Without the backslash it means it will match any character followed by in. So ".bin" will match ".in" since . means any character. Try doubling the backslash \\ or trippling. Quote Link to comment https://forums.phpfreaks.com/topic/265621-regex-for-to-block-emails-from-in/#findComment-1361314 Share on other sites More sharing options...
xyph Posted July 14, 2012 Share Posted July 14, 2012 I prefer to use greylisting for this, if you aren't already. Works WONDERS I used JEPS years ago for an exchange server I was administrating. It was free with a paid option (few more features), but it seems they only have a paid version now, with a trial. I ended up buying it just to support the guys. http://www.proxmea.com/jeps Quote Link to comment https://forums.phpfreaks.com/topic/265621-regex-for-to-block-emails-from-in/#findComment-1361460 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.