PerBonomi
5 years agoBoss
RegEx only partially working
Hi folks. Question.
I have pretty standard regex in place to filter emails, but it only works sometimes.
Say I want to filter bonomi @ spotify.com.
These are my results:
Submitted Post:
bonomi @ spotify.com
bonomi @ spotify.com
Result:
*bleep*
*bleep*
Submitted post:
bonomi @ spotify.com
bonomi@spotify.com
Result:
*bleep*
*bleep*
Submitted post:
bonomi@spotify.com
bonomi@anything.random
bonomi @ spotify.com
anyone@anydomain.net
Result:
**bleep**spotify.com
**bleep**anything.random
bonomi @ spotify.com
**bleep**
And therein lies the problem. Why is the same email filtered out on line 1 in previous posts, but not on line 3 in the last one? Do I need some kind of check for paragraph? I'd expect that not to matter?
The RegEx I'm using:
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*(\s)*(@|(\s@\s)+)+(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?((\s)*\.(\s)*))+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?