I'm trying to write a regex that our mail filter can use to analyse the message headers of an email and look for a specific header and act upon it depending on whether a word is in that header...
So:
I want to match:
X-FEAS-ANTIVIRUS: FortiSandbox:
except when it is
X-FEAS-ANTIVIRUS: FortiSandbox: uri
I've tried:
/(?:X\-FEAS\-ANTIVIRUS\:\ FortiSandbox\:\ \ (?:[^uri]*))/
But it didn't work, so tried:
/(?:[^X\-FEAS\-ANTIVIRUS\:\ FortiSandbox\:\ \ uri]*)(?:X\-FEAS\-ANTIVIRUS\:\ FortiSandbox\:)/
And neither did that.
I need to be specific about the whole "X-FEAS-ANTIVIRUS: FortiSandbox:" header so that there's no chance that the action is taken in error if it matched a different header by accident that contained "uri".
Thank you!
Related
this stuff is over my head and I hope someone can help me. Thank you for your time in advance!!
I want to determine different types of conversions based on the success URL. I have two types:
a. A job was posted on the site
b. A new tradesman has signed up
These are the two success URLs:
a. A job was posted
Unique URL: http://www.redfish.co.za/job/Some-Variable-Job-Name/success
b. A new tradesman registered
Unique URL: http://www.redfish.co.za/tradesman/Some-Variable-Trademan-Name/success
So the first regex function should looks at the URL and determine whether the URL contains the word /job/ AND /success
The second regex function should allow me to tell whether the URL contains the word /tradesman/ AND /success
Please, can you help me? I have tried to work from other examples given here but don't understand this stuff.
URL contains the word /job/ AND /success
/\/job\/.*\/success/
jsFiddle
URL contains the word /tradesman/ AND /success
/\/tradesman\/.*\/success/
jsFiddle
Explanation:
/ Indicates that what follows is a regex
'/' / has a special meaning in regular expressions (see above), so it needs to be escaped with \
job These exact characters
\/ A second /, to complete the word /job/
.* Zero or more characters (anything except a newline character)
\/success The string /success, with the \ character escaped
/ Indicates the end of the regex
I want to filter out all URL's that contain certain words, for example:
I have a URL that looks like this:
www.google.com/&SaveThis=true&SaveType=VeryFast&Page=0
And sometimes the 'Save Type' might change to slow or something. So what I want to do is show all URL's that have the 'SaveType=VeryFast' sometimes this can be in the middle of a very long URL.
I tried this:
.*SaveType=VeryFast.*
But it didn't work!
Thanks
From Tip #4 on this page, it looks like you don't need the .* on either end. That is, without the ^ and $ anchors, using SaveType=VeryFast should match any URL that contains those exact characters. It does look like word boundary anchors (\b) are not supported, so you will likely also match any URL that contains e.g. OtherSaveType=VeryFast or SaveType=VeryFastly
Otherwise, I don't see anything wrong with your expression... (?)
How can I use regular expression attribute in MVC3 on EMAIL field to give an error message if the email entered contains no-email.com?
The exact syntax will depend on the language you are using and possibly the method you are using. These examples should help.
You wouldn't normally need a regular expression to match a simple string.
But, if for some reason, it has to be regex, you would just need to escape the hyphen and dot. Like so:
no\-email\.com
Depending on what you are doing, you may need to match the rest of the email address:
(.*?)no\-email\.com
You may also want to tie "no-email.com" to the end of the string, like so:
(.*?)no\-email\.com$
If you also want to match the # sign to the domain name, do:
(.*?)#no\-email\.com$
I am trying to exclude gmail's requests from Live Http headers, but I cant
seem to get the exclude reg ex to work.
My exclude regex is this: .gif$|.jpg$|.ico$|.css$|.js$|.*mail.google.com.*
Any ideas/suggestions?
I have had the same problem and its soultion was stupid simple:
do you have enabled the check box ("exclude URL by RegExp" (or similar - I have only the german version))?
Hint: you do need to add the .* at start and end of your expression, because the request will be excludes if it contains the pattern (is must not match the complate url).
I think. You sould use "\." to catch a dot. Dot without slash is any symbol.
Like this:
\.gif$|\.jpg$|\.ico$|.css$|\.js$|.*mail\.google\.com.*
I'm trying to use Regex to get a bit if HTTP header parsing done. I'd like to use groups to organize some of the information:
Let's say I have this:
Content-Disposition: form-data; name="item1"
I'd like the result of my regex to create two groups:
contentdisposition : form-data
name : item1
I've tried several methods, but I can't seem to figure out how to do this. If name= doesn't exist then only one group should be created, but the regex should not error out.
Any ideas?
/Content-Disposition: (.*?);(?: name="(.*?)")?/ might be what you're looking for. It uses an optional greedy quantifier to get the name unless that would cause the match to fail.