-1

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-_]+)
DrC
  • 7,342
  • 1
  • 19
  • 35
Amir
  • 31
  • 5

3 Answers3

2

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?

Community
  • 1
  • 1
Chankey Pathak
  • 19,330
  • 10
  • 72
  • 119
0

Works fine with using the word (\w) with one or more quantifier

http:\/\/www\.aparat\.com\/v\/\w+
Saif Asif
  • 5,075
  • 2
  • 27
  • 46
0

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-_]+)
Amir
  • 31
  • 5