Matching REGEX website url - regex

Hello i am having trouble creating a regular expression that matches a particular set of urls.
http://www.somedomain.com/example/some-other-page/news/?p=12 Fail
http://www.somedomain.com/some-page/chat/?p=123 Pass
http://www.somedomain.com/example/path/test/chat/?p=12345 Fail
http://www.somedomain.com/example/?p=4321 Pass
http://www.somedomain.com/some-page/chat/?p=1 Fail
This is what i have so far i have ^http://www.somedomain.com(/(some-page)(/chat)(/?)(\?.*)?) I am not very comfortable with regular expressions

I solved this problem using regex101.com. this is the reg-ex i came up with ^http://www.somedomain.com(/(?:some-page|example)(/(?:‌​chat/\?p=123|\?p=43‌​21))(\?.*)?). Thanks

Related

regex change to detetct more pre-domain

I am new to regular expression and trying to learn changing the following regex, was wondering if you can help me.
The following will detect for me the links such as :
<http://www.ijs.si/software/delet.obo#VO_Broker>
regex:
<(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9]\.[^\s]{2,})
How do I change the same regex so it can also detect for me
<http://kt.ijs.si/software/delet.obo#VO_Broker>
I use the following regex to check for urls:
(\b(https?|ftp|file):\/\/[-\w+&##\/%?=~_|!:,.;]*[-\w+&##\/%=~_|])
Works fine and is a lot simpler.

Regex: Extract string between two strings

This is the issue I face
The String
nt/sign-in?wa=wsignin1.0&wtre
The Need
From that string I need to extract the following
wsignin1.0
The Attempts
So far I have tried the following Regex
wa=(.*?)(?=&amp)
This returns:
wa=wsignin1.0
The "wa=" is not supposed to be there
Perhaps with a look behind?
(?<=wa\=)(.+)(?=\&wtre)
wsignin1.0
JMeter uses Perl5-style regular expressions therefore the regex you are looking for might be as simple as:
wa=(.+?)&wtre
Demo:
Use $1$ as "Template" in your Regular Expresssion Extractor.
See How to Debug your Apache JMeter Script for more details on JMeter tests troubleshooting.
=([\w.]++)
will capture it in the first capture group. Otherwise I think #jivan has a good idea with the lookbehind. A little tweak too it:
(?<==)[\w.]++
Put this in your Regular Expression extractor:
nt/sign-in?wa=([a-zA-Z0-9\.]*)&wtre
I hope this help you.

Regular expression not working in google analytics

Im trying to build a regular expression to capture URLs which contain a certain parameter 7136D38A-AA70-434E-A705-0F5C6D072A3B
Ive set up a simple regex to capture a URL with anything before and anything after this parameter (just just all URLs which contain this parameter). Ive tested this on an online checker: http://scriptular.com/ and seems to work fine. However google analytics is saying this is invalid when i try to use it. Any idea what is causing this?
Url will be in the format
/home/index?x=23908123890123&y=kjdfhjhsfd&z=7136D38A-AA70-434E-A705-0F5C6D072A3B&p=kljdaslkjasd
so i just want to capture URLs that contain that specific "z" parameter.
regex
^.+(?=7136D38A-AA70-434E-A705-0F5C6D072A3B).+$
You just need
^.+=7136D38A-AA70-434E-A705-0F5C6D072A3B.+$
Or (a bit safer):
^.+=7136D38A-AA70-434E-A705-0F5C6D072A3B($|&.+$)
And I think you can even use
=7136D38A-AA70-434E-A705-0F5C6D072A3B($|&)
See demo
Your regex is invalid because GA regex flavor does not support look-arounds (and you have a (?=...) positive look-ahead in yours).
Here is a good GA regex cheatsheet.
To match /home/index?x=23908123890123&y=kjdfhjhsfd&z=7136D38A-AA70-434E-A705-0F5C6D072A3B&p=kljdaslkjasd you can use:
\S*7136D38A-AA70-434E-A705-0F5C6D072A3B\S*

trying to Exclude Strings from my Regex Search

I'm using the following expression to filter Oracle Java vulnerabilities from a list. This works just fine:
^(?!.*Oracle Java.*).*$
I'm having a tough time adding another string to exclude.
I got the expression from an earlier question here:
Regular Expression to exclude set of Keywords
I've tried all the examples from this link but the answer Tim gave was the only one that worked for me.
Does anyone know how I could add another string to this?
^(?!.*Oracle Java.*).*$
You can use regex alternation inside the lookahead:
^(?!.*(Oracle Java|excluded1|excluded2).*).*$

regular expression of this url

I need regular expression of url such as below
http://www.aparat.com/v/bqn5H
http://www.aparat.com/v/raozG
http://www.aparat.com/v/wKZOY
http://www.aparat.com/v/noopj
I wrote one but I think it doesn't work
http:\/\/www\.aparat\.com\/v\/([a-zA-Z0-9-_]+)
Your regex is correct. I think you are forgetting the g modifier.
See here: http://regex101.com/r/tJ1wR5
Also see: What is the best regular expression to check if a string is a valid URL?
Works fine with using the word (\w) with one or more quantifier
http:\/\/www\.aparat\.com\/v\/\w+
I checked my code and I found that this is not exactly what I need.
this is the best fit regular expression:
http:\/\/www\.aparat\.com\/v\/.*([a-z0-9-_]+)
The following code supports
http and https
www and without www
code:
^((?:https?:)?\/\/)?((?:www|m)\.)?((?:aparat(-nocookie)?\.com))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$
https://regex101.com/r/y5atof/1