wiremarket 1 Posted May 1, 2013 Report Share Posted May 1, 2013 Man this is driving me nuts. I just need a regex to use in a scrape to find any email address at a particular domain. such as my.dog@specificdomain.com or hasfleas7@SPECIFICDOMAIN.COM I've tried every regex I can think of and I just can't seem to get it quite right. Have I ever mentioned that I hate regex? Quote Link to post Share on other sites
Anonym 53 Posted May 1, 2013 Report Share Posted May 1, 2013 It is a lot easier to find a solution if you provide a context in where your problem occurs. (I used to dislike regexps too, then I saw the light. Regexp is God's gift to humanity, the liberator of a lot of problems, the best thing when compared to sliced bread. I still learn a lot, but even on the nub level like where I am, it is simply put FANTASTIC!) Quote Link to post Share on other sites
Bliss 194 Posted May 1, 2013 Report Share Posted May 1, 2013 You could use this regex [a-zA-Z0-9\._\-]{3,}(@|AT|\s(at|AT)\s|\s*[\[\(\{]\s*(at|AT)\s*[\]\}\)]\s*)[a-zA-Z]{3,}(\.|DOT|\s(dot|DOT)\s|\s*[\[\(\{]\s*(dot|DOT)\s*[\]\}\)]\s^*)[a-zA-Z]{2,}((\.|DOT|\s(dot|DOT)\s|\s*[\[\(\{]\s*(dot|DOT)\s*[\]\}\)]\s*)[a-zA-Z]{2,})?$ or this one [a-zA-Z0-9\-\_]+\@[a-zA-Z0-9\_]+\.[a-zA-Z0-9\-\_]{2,4} The top one will allow things like myemail[dot]domain[dot]com for example as well as the usual myeamail@domain.com hope that helps Quote Link to post Share on other sites
ayhoung 0 Posted May 1, 2013 Report Share Posted May 1, 2013 Try this: [a-zA-Z0-9\.]*@(specificdomain.com|SPECIFICDOMAIN.COM) Quote Link to post Share on other sites
wiremarket 1 Posted May 22, 2013 Author Report Share Posted May 22, 2013 Try this: [a-zA-Z0-9\.]*@(specificdomain.com|SPECIFICDOMAIN.COM) I'm toying with this one today, but I run into the problem that the above regex returns "@domain.com" with no prefix when those exist. Quote Link to post Share on other sites
HelloInsomnia 1103 Posted May 22, 2013 Report Share Posted May 22, 2013 This should help: [a-zA-Z0-9\.]*@(?i)specificdomain.com It will make everything after the (?i) case insensitive so that you can even have SpeCiFicDomaiN.CoM if you want. Quote Link to post Share on other sites
Anonym 53 Posted May 22, 2013 Report Share Posted May 22, 2013 None of these regexs are fully correct. There is something called IDNs, which makes it a lot harder. They are not that widely spread,but they do exist. Add to this that there are additional TLDs coming, e.g. .bank, .travel etc. Pure h*ll. Quote Link to post Share on other sites
HelloInsomnia 1103 Posted May 22, 2013 Report Share Posted May 22, 2013 None of these regexs are fully correct. There is something called IDNs, which makes it a lot harder. They are not that widely spread,but they do exist. Add to this that there are additional TLDs coming, e.g. .bank, .travel etc. Pure h*ll. He wants to match it to a specific domain though so he knows the TLD. But you're right that it's not fully correct. Here is the best version: [_a-z0-9-]+(\.[_a-z0-9-]+)*@(?i)specificdomain.com Quote Link to post Share on other sites
wiremarket 1 Posted May 22, 2013 Author Report Share Posted May 22, 2013 Damn, you guys is smart! Thanks Quote Link to post Share on other sites
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.