What's wrong with this regex? - SpamAssassin

This is a discussion on What's wrong with this regex? - SpamAssassin ; body PND_STOCK_PAYI /[^a-z](P[^a-z]{0,4}A[^a-z]{0,4}Y[^a-z]{0,4}I[^a-z] Pay88)/i (all on one line of course). In SA3.2.5, I get the following message: [5183] info: config: invalid regexp for rule PND_STOCK_PAYI: /[^a-z (P[^a-z]{0,2}A[^a-z]{0,2}Y[^a-z]{0: missing or invalid delimiters With SA3.1.7, there's no problem. /Per Jessen, Zürich...

+ Reply to Thread
Results 1 to 7 of 7

Thread: What's wrong with this regex?

  1. What's wrong with this regex?

    body PND_STOCK_PAYI /[^a-z](P[^a-z]{0,4}A[^a-z]{0,4}Y[^a-z]{0,4}I[^a-z]
    Pay88)/i

    (all on one line of course).

    In SA3.2.5, I get the following message:

    [5183] info: config: invalid regexp for rule PND_STOCK_PAYI: /[^a-z
    (P[^a-z]{0,2}A[^a-z]{0,2}Y[^a-z]{0: missing or invalid delimiters

    With SA3.1.7, there's no problem.


    /Per Jessen, Zürich


  2. Re: What's wrong with this regex?

    > body PND_STOCK_PAYI
    > /[^a-z](P[^a-z]{0,4}A[^a-z]{0,4}Y[^a-z]{0,4}I[^a-z]
    > Pay88)/i
    >
    > (all on one line of course).
    >
    > In SA3.2.5, I get the following message:
    >
    > [5183] info: config: invalid regexp for rule
    > PND_STOCK_PAYI: /[^a-z
    > (P[^a-z]{0,2}A[^a-z]{0,2}Y[^a-z]{0: missing or invalid
    > delimiters
    >
    > With SA3.1.7, there's no problem.
    >
    >
    > /Per Jessen, Zürich


    The regexp as shown is not the same as in the error message.

    The code shows items like {0,4} while in the error message they are {0,2}
    The code the last characters of the rule are "Pay88)/i", while in the regexp in error message has last characters as "[^a-z]{0".

    The error is not from the regexp you think it is.


  3. Re: What's wrong with this regex?

    Per Jessen wrote:
    > body PND_STOCK_PAYI /[^a-z](P[^a-z]{0,4}A[^a-z]{0,4}Y[^a-z]{0,4}I[^a-z]
    > Pay88)/i
    >
    > (all on one line of course).
    >
    > In SA3.2.5, I get the following message:
    >
    > [5183] info: config: invalid regexp for rule PND_STOCK_PAYI: /[^a-z
    > (P[^a-z]{0,2}A[^a-z]{0,2}Y[^a-z]{0: missing or invalid delimiters
    >


    This is the not the same regex ({0,2} vs {0,4}). you should copy-paste
    the re and post it, as there are more eyes to spot a typo...

    > With SA3.1.7, there's no problem.
    >
    >
    > /Per Jessen, Zürich
    >



  4. Re: What's wrong with this regex?

    Jari Fredriksson wrote:

    >> body PND_STOCK_PAYI
    >> /[^a-z](P[^a-z]{0,4}A[^a-z]{0,4}Y[^a-z]{0,4}I[^a-z]
    >> Pay88)/i
    >>
    >> (all on one line of course).
    >>
    >> In SA3.2.5, I get the following message:
    >>
    >> [5183] info: config: invalid regexp for rule
    >> PND_STOCK_PAYI: /[^a-z
    >> (P[^a-z]{0,2}A[^a-z]{0,2}Y[^a-z]{0: missing or invalid
    >> delimiters
    >>
    >> With SA3.1.7, there's no problem.
    >>
    >>
    >> /Per Jessen, Zürich

    >
    > The regexp as shown is not the same as in the error message.


    I assumed that was because the error-message cuts it short, but you're
    absolutely right, I had another unfinished rule with the same name.
    Thanks for making me look again.


    /Per Jessen, Zürich


  5. Re: What's wrong with this regex?

    Per Jessen wrote:
    > body PND_STOCK_PAYI /[^a-z](P[^a-z]{0,4}A[^a-z]{0,4}Y[^a-z]{0,4}I[^a-z]
    > Pay88)/i
    >
    > (all on one line of course).
    >
    > In SA3.2.5, I get the following message:
    >
    > [5183] info: config: invalid regexp for rule PND_STOCK_PAYI: /[^a-z
    > (P[^a-z]{0,2}A[^a-z]{0,2}Y[^a-z]{0: missing or invalid delimiters
    >
    > With SA3.1.7, there's no problem.
    >
    >
    > /Per Jessen, Zürich
    >
    >
    >

    As the others have said, it's not the same regex. The one that isn't
    working is missing a ']' after /[^a-z.


  6. Re: What's wrong with this regex?

    Per Jessen wrote on Fri, 18 Jul 2008 12:40:27 +0200:

    > [^a-z](P[^a-z]{0,4}A[^a-z]{0,4}Y[^a-z]{0,4}I[^a-z]
    > Pay88)


    Regex Coach doesn't complain about it, but don't you need a quantifier
    after the first [^a-z] range?

    Kai

    --
    Kai Schtzl, Berlin, Germany
    Get your web at Conactive Internet Services: http://www.conactive.com


  7. Re: What's wrong with this regex?

    Kai Schaetzl wrote:
    > Per Jessen wrote on Fri, 18 Jul 2008 12:40:27 +0200:
    >
    >> [^a-z](P[^a-z]{0,4}A[^a-z]{0,4}Y[^a-z]{0,4}I[^a-z]
    >> Pay88)

    >
    > Regex Coach doesn't complain about it, but don't you need a quantifier
    > after the first [^a-z] range?


    no, the default quantifier is {1,1}.

    as said earlier, this RE is correct. the error is in another one.


+ Reply to Thread