I have the following (dummy) strings, that in reality are part of URLs:
methods/english
methods/english/dummy
I want my regex to exclude strings that have a slash after english. So the second string should not match the regex.
I tried this regex:
/methods/.*/[^/]
So that it excludes the slash character.
But with this logic it still matches with methods/english/dummy. I can't figure out why.
You can use
^methods/[^/]+$
See the regex demo.
Details:
^ - start of stringmethods/ - a literal string[^/]+ - one or more chars other than /$ - end of string.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With