Home > OS >  Find words not containing a slash
Find words not containing a slash

Time:09-21

I have links like below: https://www.aparat.com/v/xxx and https://www.aparat.com/v/xxx/yyy

I want to find the links not having slash after /v/. So the first link is ok and the second one is not.

I have tried lots and lots of regex but all of them matched the links until the first slash like: enter image description here Where:

  • \/v\/ - The /v/ part
  • [^\/]* - Any character that is not a slash /. Since the next pattern is already $, then this must span up to the end of the string.
  • $ - End of string

Update

On top of the rules above, we could allow an additional slash if it isn't followed by any characters by simply appending the optional /? at the end:

\/v\/[^\/]*\/?$

enter image description here

  • Related