Alex Rivera | Logout

Regular expression to allow backslash in C#

Asked 2013-02-01T07:04:22.270
13

Can anyone provide me with regex for validating string which only should not allow any special characters except backslash. I tried

var regexItem = new Regex("^[a-zA-Z0-9\\\ ]*$");

But it doesn't seem to work

Edit
Report

1 Answer

0

You would have to escape the \ for regex as well as C# string by adding 4 \s for matching a single \.

answered 2013-02-01T07:06:43.047

Your Answer