Home Ask Login Register

Developers Planet

Your answer is one click away!

user2721609 February 2016

Not allowing \ through regular expression

I have created the below regular expression:


To not allow forward slash and it works. I also doesn't have to allow forward slash. How can I modify this regular expression.

I tried the below one but it doesn't work:



RAnders00 February 2016

The backslash is a special character in regular expressions. That's why you need to escape it with another backslash, so it loses its special meaning (don't copy it into your code yet, look below):


If your programming language also uses backslashes for escaping, you might need to apply 4 backslashes: First, they are parsed by the compiler, and later, the regex engine will process them another time.


Post Status

Asked in February 2016
Viewed 1,513 times
Voted 5
Answered 1 times


Leave an answer

Quote of the day: live life