Weird match

These are old archives. They are kept for historic purposes only.
Post Reply
Wiggle
Posts: 19
Joined: Sat Mar 05, 2005 11:52 pm
Location: Belgium

Weird match

Post 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.
All spelling mistakes, grammatical errors and stupid comments are intentional.
Jobe
Official supporter
Posts: 1180
Joined: Wed May 03, 2006 7:09 pm
Location: United Kingdom

Re: Weird match

Post 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.
Your IP: Image
Your Country: Image
Wiggle
Posts: 19
Joined: Sat Mar 05, 2005 11:52 pm
Location: Belgium

Re: Weird match

Post 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.
All spelling mistakes, grammatical errors and stupid comments are intentional.
Jobe
Official supporter
Posts: 1180
Joined: Wed May 03, 2006 7:09 pm
Location: United Kingdom

Re: Weird match

Post by Jobe »

It could probably be that the regex system used doesnt support \x<hex>
Your IP: Image
Your Country: Image
Wiggle
Posts: 19
Joined: Sat Mar 05, 2005 11:52 pm
Location: Belgium

Re: Weird match

Post by Wiggle »

Kinda weird then that the default spamfilter.conf containts \x01?
All spelling mistakes, grammatical errors and stupid comments are intentional.
Jobe
Official supporter
Posts: 1180
Joined: Wed May 03, 2006 7:09 pm
Location: United Kingdom

Re: Weird match

Post by Jobe »

True, unless it just doesn't support them in [] character classes.
Your IP: Image
Your Country: Image
Post Reply