[pmwiki-devel] Email pattern...

The Editor editor at fast.st
Thu May 31 18:39:24 CDT 2007


On 5/31/07, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Thu, May 31, 2007 at 01:53:46PM -0700, Martin Fick wrote:
> > --- "Patrick R. Michaud" <pmichaud at pobox.com> wrote:
> > Well, from here:
> >
> > http://www.regular-expressions.info/email.html

The link above was quite interesting reading. No clue my simple
question would generate such interesting discussion.

For my purposes, however, the double slash solved the basic problem.
I'm curious why the single slash did not escape the dot while the
double slash did. Can any one explain that?

/^.+ at .+\..+$/

Amazing how complex this was.

Cheers,
Dan

PS. Here's the official rfc 822 standard pattern according to the link
above, in case anyone wants it (remove line breaks).

(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \x00-\x1F]+(?:(?:
(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.
|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t]
)*(?:[^()<>@,;:\\".\[\] \x00-\x1F]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=
[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(
?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \
x00-\x1F]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\
[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])
*(?:[^()<>@,;:\\".\[\] \x00-\x1F]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[
\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*
))*|(?:[^()<>@,;:\\".\[\] \x00-\x1F]+(?:(?:(?:\r\n)?[ \t])+|\Z|(
?=[\["()<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)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \x00
-\x1F]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([
^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*))*
)?;\s*)



More information about the pmwiki-devel mailing list