regular expression doesn't seem to work

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
aty154
New user
New user
Posts: 9
Joined: 2006-05-25 14:45
Location: Pakistan/Karachi
Contact:

regular expression doesn't seem to work

Post by aty154 » 2006-07-06 08:39

I try to use regular expression for search particular word in message body and delete that email.

Following are selection and values I give in rule
Predefined Field = body
Search type = Regular Expression
Value = \bsex\b

I want to use regular expression cause if I use contain in search type then good emails can be deleted. This is only one of rule I am using there are many rules that are using regular expression also not working.

I set rule and try to test by sending email and put word in body but rule doesn’t seem to work. Please tell me what is problem.

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2006-07-06 15:51

Hmm. I'm no regex expert, but I don't know of the syntax \b? Where have you found that info? I've tested that regex using a couple of online regex tests and none of them match.

As far as I know, you should use .* if you want to match any character(s). Not \b

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Post by ^DooM^ » 2006-07-06 16:01

Try this regex. This will look for the word sex in your document only if there is a space preceding the word sex though.

Code: Select all

(\s[s][e][x])
Let us know how you get on.
If at first you don't succeed, bomb disposal probably isn't for you! ヅ

aty154
New user
New user
Posts: 9
Joined: 2006-05-25 14:45
Location: Pakistan/Karachi
Contact:

Post by aty154 » 2006-07-07 07:53

I try using

Code: Select all

(\s[s][e][x])

but rule don't work

I get regular expression

Code: Select all

\bsex\b 
from Regex Buddy software

I don't understand hmailserver Documentation recommand to use regex buddy tool then why regular expression is not working.

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2006-07-07 09:37

aty154 wrote:I don't understand hmailserver Documentation recommand to use regex buddy tool then why regular expression is not working.
Where does the hMailServer documentation recommend this? I've searched the documentation but could not find any reference to this tool. The only thing I've found is a link to the site http://www.regular-expressions.info/. This site has many links to different 3:rd party tools and libraries. So where did you find this recommendation?

Also, that the tool you use should suggest \bsex\b sounds weird to me. To me this does not even look like a regular expression. My guess is that you've misunderstood something in the software you use.

There are several online regex tests you can use. Here's one simple:
http://www.dotnetcoders.com/web/Learnin ... ester.aspx

And as I wrote, you can use .* to match <anything>. So in your case, you should be able to use .*SEX.*
But again, I'm no RegEx expert..

^DooM^
Site Admin
Posts: 13861
Joined: 2005-07-29 16:18
Location: UK

Post by ^DooM^ » 2006-07-07 13:44

.*sex.* will check the whole document and if it contains the letters sex anywhere it will return true. My way of doing it was more specific and only matched true if there was a space preceding the word sex. Both of these ways should work. If I get chance over the weekend I will try this out myself.

Post Reply