Page 1 of 1

Weird match

Posted: Mon May 12, 2008 10:41 am
by Wiggle
Hi,

I'm trying to spamfilter privmsg's that contain DCC SEND/RESUME/CHAT, but where the DCC is not preceded by this special \x01 character.

I hade the following regex: [^\x01]+DCC (SEND|CHAT|RESUME)
And this seemed to match: DCC SEND versions.txt 1359719488 1024 17115

Now, I wonder why. Since clearly, this DCC SEND is NOT preceded by one or more characters that do NOT equal \x01?

Any thoughts/suggestions would be appreciated.

Re: Weird match

Posted: Mon May 12, 2008 5:24 pm
by Jobe
Your regex matches where 1 or more characters preceding "DCC" are NOT \x01, what you wanted was where there are NO characters before DCC, like this:
^DCC (SEND|CHAT|RESUME)

The ^ means that DCC must be the FIRST thing in the message with NOTHING before it.

Re: Weird match

Posted: Mon May 12, 2008 9:53 pm
by Wiggle
Hey,

I know that is what I should be using when I wanted no characters before it and understand what ^ is, but imagine I want to catch this string mid-sentence, when there are other characters before it, that do not match \x01.

The point is that I believe in this example, that regex should not match, and it does. I'm wondering why.

Re: Weird match

Posted: Tue May 13, 2008 8:31 am
by Jobe
It could probably be that the regex system used doesnt support \x<hex>

Re: Weird match

Posted: Tue May 13, 2008 4:57 pm
by Wiggle
Kinda weird then that the default spamfilter.conf containts \x01?

Re: Weird match

Posted: Tue May 13, 2008 8:21 pm
by Jobe
True, unless it just doesn't support them in [] character classes.