regular expression of this url - regex

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

Related

Regular expression to find last dot in request URI

I am trying to write a regular expression for apache virtual host configuration that will map request if URI doesn't have certain extensions. Below expression I have written.
^\/bookdata\/.+\.(?!jpg|mp3|mp4|zip|doc|pdf|xls|xlsx).*$
Below URI is not matching to this expression which is perfectly fine.
/bookdata/rw0/media/Q2e_00_RW_U08_Q_Classroom.mp3?fd=1
My problem with below URI which is matching with this expression due to two dots.
/bookdata/rw0/media/ELM2_U02_Track06_Chart2.8.mp3?fd=1
Any small help will be appreciated.
Put the neg. lookahead right at the start, like so
^(?!.*\.(?:jpg|mp3|mp4|zip|doc|pdf|xls|xlsx))\/bookdata\/.+$
See a demo on regex101.com.
As I know request URI doesn't contain request params(after question mark)
So you can ommit .* at the end of your regex then you can match your prefer uris.
This happen because you say that your uri end by those extension must not match.

Matching REGEX website url

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

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.

Can someone tell me the regular expression for this?

I am working with regular expressions, I need to create an expression for validating strings against the following scenario:
Solution.<word1|word2|word3>.<word4|word5>.anyword.(any word containing proj in it)
I tried
Solution.\b(word1|word2|word3)\b.\b(word4|word5)\b.(.*).\b(.*proj)\b
But this allows strings like Solution.word1.word4.blabla.blabla.csproj, meaning it allows anything before the proj because of the .*.
Can someone help me with this??
Looks like you need this regex:
Solution\.(word1|word2|word3)\.(word4|word5)\.([^.]+)\..*?\bproj\b
RegEx Demo
You might want to try (need to escape the . and allow capturing group to have chars except .):
Solution\.\b(word1|word2|word3)\b\.\b(word4|word5)\b\.([^\.]*)\.\b([^\.]*proj)\b
It's hard to consider the actual strings you want to allow without more clarification.
You can try the following regular expression.
Solution\.word[123]\.word[45]\.\w+\.\w*proj\b

RegEx: Not contain specific file types

I'm searching for a regular expression that hits everything that is NOT ending with ".png" or ".jpg". I want to find out URLs that do not request an image file.
I found something like this: ([^\s]+(\.(?i)(jpg|png))$) but this is pretty much the opposite of what I want.
Is there an easy way to reverse this? Or is this expression totally wrong?!
Thanx in advance.
Jan
This can be done using negative lookahead:
([^\s]+(\.(?i)(?!jpg$|png$)[^\s]+)$)
That expression will match file.gif and file.png2 but not file.png.
See also: Regex help. Lighttpd rewrite rule