dws: No no, he wants to reverse the test.

The problem is that he uses a zero-width assertion, hence the \. is required to be at the end of the string.. so that obviously won't work

jwx: basically your regex says the period may not be followed by 'br', 'com', 'net', or 'org' .. but you're also not permitting anything else to follow it. A solution, although not very pretty, would be to explicitly match a word after the period:

.+\.(?!br|com|net|org)\w*

The zero-width assertion will make sure that the word doesn't begin with 'br', 'com', 'net', or 'org'. I can't think of any top-level domains that begin with those but aren't equal to it, but if you're worried then this should work:

.+\.(?!(?:br|com|net|org)$)\w*

BTW, as dws says.. a pretty heavy-handed way to deal with your email.. (I'm in 'nl' myself, so if I'd email you it would be discarded as spam?)

•Update: changed \w+ to \w* to discard addresses that end in a period as "spam"


In reply to Re: Re: Email suffix matching with a negative look-ahead regexp by xmath
in thread Email suffix matching with a negative look-ahead regexp by jxz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.