On Fri, 8 Apr 2016 09:02:36 -0300
Robert Boyl wrote:

> Hi, everyone!
> 
> Sorry, lame with regex.
> 
> How can I make a rule to catch:
> 
> Need to buy a product ?
> 
> And also catch "need to buy a product    ?"
> 
> Note the extra spacing.

The body is normalized, so all consecutive whitespace becomes a single
space.

If you need to detect multiple spaces you need the rawbody. 

> Tried this, didnt work:
> 
> describe TEST123    test
> body     TEST123        /\bNeed to buy products *\?\b/i
> score    TEST123 0.0

Scoring a rule at zero stops it being used, which is why it failed.

There's no boundary between punctuation and a space, so
replace the final \b with a  $ (for clarity) or leave it out. Usually
it's better not to wrap phrases like this in a pair of boundaries.
There's no chance of extra letters changing the meaning - it just
makes it a little easier to beat.


> If possible, also make it catch if more than 1 question mark :)

Without the final \b it will match. Otherwise use \?+.

Reply via email to