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?
How can i match a string that does not finish with / . I
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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: