Email matching problem

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: Email matching problem

Post by prometheuzz »

GeertDD wrote:
prometheuzz wrote:...
The problem is that now the first part of the email can start and/or end with a dot. One way to prevent this is using lookaround.
...
All very true! Note that the OP asked for a loose regex. You can make the regex more and more exact, but that is a decision for the OP.
You can also extend your regex so that there cannot occur two dots in succession, but it would make the regex more and more "voodoo-like" (not for you, but most regex-mortals)
; )

But it's good that you posted a different version of it: now the OP can decide which one to use.
User avatar
GeertDD
Forum Contributor
Posts: 274
Joined: Sun Oct 22, 2006 1:47 am
Location: Belgium

Re: Email matching problem

Post by GeertDD »

prometheuzz wrote:2 - Since validating e-mail addresses will not be done on large strings*, the time wasted on backtracking when an invalid addresses entered will be next to nothing.

* the text field where the user enters his/her e-mail address should be restricted. No multi line and a fixed width.
It was just a suggestion. I would use possessive matching anyway because you never know and cannot restrict what POST data contains.
User avatar
prometheuzz
Forum Regular
Posts: 779
Joined: Fri Apr 04, 2008 5:51 am

Re: Email matching problem

Post by prometheuzz »

GeertDD wrote:... because you never know and cannot restrict what POST data contains.
Also true, Geert.
Post Reply