Need REGEX Expert

gacoon

Pre-takeoff checklist
Joined
Mar 30, 2015
Messages
157
Location
S50 and KDVT
Display Name

Display name:
Gerry
Sorry to say I've tried for a couple of mornings to write a Regex expression to do the following:

line contains the following three items, they would be an AND condition:
1) word: "Unsubscribe"
2) character string: "http:"
3) character string: "johndoe"

Thanks for any help,
Gerry
 
Shell? grep Unsubscribe | grep http: | grep johndoe

Perl?

($_ =~ m/Unsubscribe/) && ($_ =~ m/http:/) && ($_ =~ m/johndoe/)
 
>Will they be in any particular order?

Yes ordered as first post:

1) word: "Unsubscribe"
2) character string: "http:"
3) character string: "johndoe"
 
Shell? grep Unsubscribe | grep http: | grep johndoe

Perl?

($_ =~ m/Unsubscribe/) && ($_ =~ m/http:/) && ($_ =~ m/johndoe/)
Those wont work for me. Needs to use the basic REGEX syntax, expression must pass a testor such as this one:

https://regex101.com/

this will be used in Comcasts user developed SPAM filter area - they have an option that allows REGEX formulas to scan parts of incoming email. Of course they have no documentation on how to use it.

thanks, gerry
 
Unsubscribe.*http:.*johndoe
 
Unsubscribe.*http:.*johndoe
Will fail on " Unsubscribe johndoe@fakemail.org http://foo.com"

Those wont work for me. Needs to use the basic REGEX syntax, expression must pass a testor such as this one:

https://regex101.com/

this will be used in Comcasts user developed SPAM filter area - they have an option that allows REGEX formulas to scan parts of incoming email. Of course they have no documentation on how to use it.

thanks, gerry
Will it take nested groups? ((Unsubscribe.*johndoe.*http: )|(johndoe.*Unsubscribe.*http: )|etc|etc|etc)
 
[Uu]nsubscribe.+http:.+johndoe

Is there something more complicated I'm not seeing here?
 
I could not get either of the these two to pass the testor at: https://regex101.com/
using the following test string:

USA Unsubscribe \\http:/xfinity.amazon.johndoe@comcast.net

Unsubscribe.*http:.*johndoe
[Uu]nsubscribe.+http:.+johndoe

Both fail with no matches, the order would be nice but even it identified lines containing those values would do it.

The psuedo code for this is:

If line contains Word <XYZ> and character string <abc> and character string <xyz>
 
I tried a different REGEX tester ( https://regexr.com/ ) and:

[Uu]nsubscribe.+http:.+johndoe works - thank you DaleB
Unsubscribe.*http:.*johndoe works also thank you dsmpilot

Now I'll try it in my comcast profile, that will be interesting.

Thank you both!
 
I could not get either of the these two to pass the testor at: https://regex101.com/
using the following test string:

USA Unsubscribe \\http:/xfinity.amazon.johndoe@comcast.net

Unsubscribe.*http:.*johndoe
[Uu]nsubscribe.+http:.+johndoe

Both fail with no matches, the order would be nice but even it identified lines containing those values would do it.

The psuedo code for this is:

If line contains Word <XYZ> and character string <abc> and character string <xyz>

Looks like a pass to me. :confused2:

Screen Shot 2018-06-28 at 6.40.36 PM.png
 
Update both these scripts work fine in the Comcast REGEX filter capability - I am now able to weed out a really knarly piece of SPAM that was coming several times a day. I had been studying its format and could see one way to id it.
So thanks to you guys I got it and learned some stuff, thanks,
Gerry
 
I wasn't much good with regex until I started needing to use Splunk's rex command. I'm picking up speed quickly.
 
Back
Top