Analytics - Match URL with Parameters - regex

I am having difficulties registering this URL as a goal. It is the final URL.
https://foo.com/Home/Search?Message=Success&show=True
I have tried matching the exact URL, but that doesn't work. I've tried various regEx patterns, but I don't know how to match a specific parameter/value.
Any help would be very much appreciated.
Thank you.

To match exactly this URL your regex should be like :
https:\/\/foo.com\/Home\/Search\?Message=Success&show=True

Related

Regex for this URL, http://www.chip.de and this domain chip.de

I am trying to create a regex to look for similar URL and domain like this below
*chip.de
http://www.chip.de*
I tried to use the regex expression
http?:\/\/([\w\.-]+)([\/\w \.-]*)
It did not capture the URL.
I tried to use the url, https://www.regextester.com/99497 to test it out and it failed..
What am I missing?
Please create two rules for domain and URL
Thank you
If you're simply looking for regex that will match URLs which include chip.de then please try this and let me know if it is sufficient:
https?\:\/\/www\.chip\.de.*

Django similar url pattern issue

I am working on a products comparison module and have url patterns like below:
path('comparison/<slug:slug1>-vs-<slug:slug2>/', views.compare_two_products, name="compare_two_products"),
path('comparison/<slug:slug1>-vs-<slug:slug2>-vs-<slug:slug3>/', views.compare_three_products, name="compare_three_products"),
The issue is that Django (3.2.6) always matches the first pattern and returns 404 when I try to access the second pattern. However if I comment out the first pattern, then it matches the third pattern just fine. I want to get both the patterns working in the format slug-vs-slug-vs-slug. Any suggestions on what I might be doing wrong ?
Thanks in advance.
Just change the order or URLs, like
path('comparison/<slug:slug1>-vs-<slug:slug2>-vs-<slug:slug3>/', views.compare_three_products, name="compare_three_products"),
path('comparison/<slug:slug1>-vs-<slug:slug2>/', views.compare_two_products, name="compare_two_products"),
that should work

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/:

Regular expression to match string from url

I want to match shop name from a url .Please see the example below. Its for url redirection in a word press application.
See the examples given below
http://example.com/outlets/19-awok?page=2
http://example.com/outlets/19-awok
http://example.com/outlets/159-awok?page=3
In all cases i need to get only awok from the url .It will be the text coming after '-' and before query string .
I tried below and its not working
/outlets/(\d+)-(.*)? => /shop/$2
Any help will be greatly appreciated.
You can use this regex:
/outlets/\d+-([^?]+)?
Trailing ? is used to strip previous query string.

How can I make this regex for a URL more specific?

I have the following regex that attempts to match URLs:
/((http|https):(([A-Za-z0-9$_.+!*(),;/?:#&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*(),;/?:#&~=%-]*))?([A-Za-z0-9$_+!*();/?:~-]))/g
How can I modify this regex to only match URLs of a single domain?
For example, I only want to match URLs that begin with http://www.google.com?
This should simplify my regex, but I'm too much of a regex noob to get it working (after all these years...)
Did you write that RegEx? I don't know what it's trying to do, but it certainly doesn't match URLs correctly. Here's something it matches:
http:###9#?~
which I'm pretty sure isn't a valid URL.
You shouldn't be using RegEx to match URLs like this. You haven't said what language you're working in, but use whatever its equivalent of urlparse is..
Here's a relevant question: How do you validate a URL with a regular expression in Python?