Excluding in Live HTTP Headers plugin for Firefox - regex

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.*

Related

How to fix regex url pattern

I need to fix my url pattern:
/^((http(s)?(\:\/\/)){1}(www\.)?([\w\-\.\/])*(\.[a-zA-Z]{2,4}\/?)[^\\\/#?])[^\s\b\n|]*[^\.,;:\?\!\#\^\$ -]/
I thought this regex was ok, but it is not working for urls like: https://xx.xx (without www). 'www' should be optional ((www.)?). Where is the bug?
The problem is not in the (www\.)? part but that parts after that.
Take a look at the [^\\\/#?] and the [^\.,;:\?\!\#\^\$ -] parts.
So a valid URL would be https://xx.xx plus none of \/#? plus none of .,;:?!#^$_- making the url valid if you add those, for example https://xx.xx11.
I do advice you to not try to create your own regex because you are missing a lot!
For example, tlds like .amsterdam are valid. And why are you capturing so many groups?
Your regex as an image made with https://www.debuggex.com/:

Regex for only if if a character is present then it can be succeeded

I am trying to construct a simple regex for detecting URLs. My progress is this regex:
^((https?):\/\/)?[\w.]*[\w]+\.[a-z]{3}\/?([\w\?\#.=-]+\/?)*$ But this is not actually what I want.
This can detect URLs like:
https://something.com
www.stackoverflow.com
subdomain.domain.com/something/photo.png
But this also detects
subdomain.domain.communication
My goal is this:
There must be three characters in the domain ending (.com, .org, .net). There can be a / or not after the domain ending. But if only a / is present it should look into futher regex else it shold not match. Like it should detect:
https://somewebsite.com
https://somewebsite.com/
https://somewebsite.com/webpage/some#section
But not:
https://something.commmm/
Try
^(https?:\/\/)?([\w]+\.)+[a-z]{3}(\/[\w\?\#.=-]+)*\/?$

Conditional Regex to match url

I am trying to make a if/then condition to match the url, but I can't seem to get it to work. I am trying to match URLs and then capture the non-optional group. So - if a url comes in like this:
/en/testing.aspx
I want to capture /testing.aspx
if the url comes in like this:
/testing.aspx
I want to capture /testing.aspx
Is there an easy way to do this using regex?
EDIT:
The Url can be multi-part url, like /en/sub1/sub2/testing.aspx - I essentially want everything after "/en/".
use regex \/en(\/.+)$
Check this out
edited
https://regex101.com/r/lwowhi/6
If there is "/en/" in the URL and you still want to capture /testing.aspx then here is an edit (?:\/en)*(\/.+)$
https://regex101.com/r/lwowhi/8
You can use a greedy regex which will consume everything up until the final forward slash. Then, capture everything which comes after that point.
^.*?(?:\/en)?(\/.*)$
Demo
Guessing all pages are .aspx then use group.
regex: .(/..aspx)
this will match "/testing.aspx" in all bellow samples
/testing.aspx or
/en/testing.aspx or
www.abc.com/en-us/testing.aspx

Regular expression to match only domain from URL

I'm struggling with forming a regex that would match:
Just domain in case of URL
Whole string in case of no URL
Acceptance test (regex should match bold text):
http://mozart.co.uk
https://avocado.si/hmm
http://www.qwe123qwe.com
Starbucks
Benchmark 123
So far I've come up with this:
([^\/\/]+)(?:,|$)
It works fine, but not for URLs with trailing slash on the end. How can I modify the expression to include full path (everything on the right side of http(s)://) as well? Thank you.
This regex will match them if it starts with http:// or https:// until the next slash. If it doesn't start with http:// nor https:// then it will match the whole string. Close enough?
(?:^https?:\/\/([^\/]+)(?:[\/,]|$)|^(.*)$)
I should note that most languages have functions built in to properly parse URLs and these are preferable.
You should note that I've got 2 sets of capturing parentheses, so depending on your language that may be significant.
Maybe that ^(http[s]?:\/\/)?(.*)$. Play here: https://regex101.com/r/iZ2vL4/1
This will have Matching groups, the domain you want will be in the 4th matching group.
/^((http[s]?|ftp):\/\/)?\/?([^\/\.]+\.)*?([^\/\.]+\.[^:\/\s\.]{1,3}(\.[^:\/\s\.]{1,2})?(:\d+)?)($|\/)([^#?\s]+)?(.*?)?(#[\w\-]+)?$/mg
Regex101.com workbench to check out your URLs just paste them in the "TEST STRING" Textbox to test it out.
Don't recall where I got this... so I don't know who to credit. But it's pretty slick!

How 'Exclude URLs With regex' In Live HTTP headers

I want to exclude some urls from Live HTTP headers (firefox add-on).
so in Config area i checked Exclude URLs With regex and put the string below in it:
.gif$|.jpg$|.ico$|.css$|.js$|.png$|.bmp$|.jpeg$|google$|bing$|alexa$
i want to remove all images from capturing and any url that contains :
css - js - google - bing - alexa
what is the problem about my regex and would you please fix it for me?
thanks in advance
. means "any char"
$ means "the end of the string"
That said:
.gif$ will match "any string ending with gif that is at least 4-char long"
google$ will match "any string ending with google"
I guess you were looking for something like:
[.](gif|jpg|ico|css|js|png|bmp|jpeg)$|\b(google|bing|alexa)\b
Maybe your regexps get autoanchored with ^ and $ by the tool you're using. In this case, use .* additionally:
.*[.](gif|jpg|ico|css|js|png|bmp|jpeg)$|.*\b(google|bing|alexa)\b.*