How can i match a string that does not finish with /
. I know I can do that /\/$/
and it will match if string does finish with /
, but how can I test to see if it doesn't?
相关问题
- Improve converting string to readable urls
- Regex to match charset
- Regex subsequence matching
- Accommodate two types of quotes in a regex
- Set together letters and numbers that are ordinal
相关文章
- Optimization techniques for backtracking regex imp
- Regex to check for new line
- Allow only 2 decimal points entry to a textbox usi
- Comparing speed of non-matching regexp
- Regular expression to get URL in string swift with
- 请问如何删除之前和之后的非字母中文单字
- Lazy (ungreedy) matching multiple groups using reg
- when [:punct:] is too much [duplicate]
You can use a negative character class:
This however requires that the string contains at least one character. If you also want to allow the empty string you can use an alternation:
A different approach is to use a negative lookbehind but note that many popular regular expression engines do not support lookbehinds:
[^\/]$
^
will negate any character class expression.You can say "not character" by doing
[^...]
. In this case, you can say "not backslash by doing":/[^\/]$/