How do you quote asterisk with NewsBin 3.32 regular expressi

Tips on writing regular expressions for searching the post list

Moderators: Quade, dexter

How do you quote asterisk with NewsBin 3.32 regular expressi

Postby Tony » Mon Oct 15, 2001 5:07 pm

Hello,

I've had good luck using NewsBin 3.32 regular expressions. Now I'm trying to get a little more fancy. I am trying to block subject lines containing palindrome phrases like this:
"** word1 word2 word1 **"
In this case, I want to match a literal asterisk. In perl, you do this by quoting the asterisk with the backslash character. Like this:
"\*\* word1 word2 word1 \*\*"
However this does not work for me in NewsBin. In fact I can't get any regex to work using backslash to quote the asterisk character. How do you do it?
Tony
 

RE: How do you quote asterisk with NewsBin 3.32 regular expr

Postby Axthor » Mon Oct 15, 2001 11:36 pm

Hi

Try [*][*] words [*][*]

In the past the square brackets were used to specify special
chars such as the period [.].

Axthor
Axthor
Seasoned User
Seasoned User
 
Posts: 173
Joined: Fri Aug 31, 2001 6:43 pm
Location: Vancouver BC

Registered Newsbin User since: 04/20/03

RE: How do you quote asterisk with NewsBin 3.32 regular expr

Postby Tony » Thu Oct 18, 2001 5:23 pm

>Hi
>
>Try [*][*] words [*][*]
>
>In the past the square brackets
>were used to specify special
>
>chars such as the period [.].
>
>
>Axthor

Thank you very much! Your suggestion to use [*] to quote an asterisk worked.

For the record, here's exactly what I settled on. It works quite nicely for me, and maybe it will help someone else.
I entered this in the subject reject list:

^[*][*].*[*][*]$

Explanation:

^ matches beginning of line
[*] matches an asterisk
.* matches everything
$ matches end of line

Thus ^[*][*].*[*][*]$ entered in the subject reject list will reject all subjects that start and end with two asterisks. Anything (any number of any characters) can be between the starting and ending pairs of asterisks. In my experience, such subjects are more than 99% likely to be spam.
Tony
 

RE: How do you quote asterisk with NewsBin 3.32 regular expr

Postby dexter » Mon Oct 22, 2001 1:15 am

I'm surprised. The backslash does work when you are escaping a dot but it doesn't work with other characters including the asterisk and I just tested it with a square bracket. It should work consistently, we'll look into it. Your solution is fine, though, the square brackets define a set of characters from which to match so you could put more than asterisks, you could put tildes or some of the other strange characters I've seen spammers frame their subjects with.
User avatar
dexter
Site Admin
Site Admin
 
Posts: 9514
Joined: Fri May 18, 2001 3:50 pm
Location: Northern Virginia, US

Registered Newsbin User since: 10/24/97

Postby Smite » Wed Aug 27, 2003 6:21 pm

So ever find out why you can't escape a square bracket? Just ran into it again, so... :P
User avatar
Smite
Katamari Damacy Addict
 
Posts: 5318
Joined: Sat May 19, 2001 1:54 am
Location: Alberta, Canada

Registered Newsbin User since: 03/27/03


Return to Regular Expressions

Who is online

Users browsing this forum: No registered users and 2 guests