I am working with ASP.NET 3.5, VB.NET, and I am trying to validate some inputs through a regular expression.
My expression is:
^[a-zA-Z'_''-''/'' ''\''@''&''.'',''ç''Ç''ö''Ö''I''ı''i''İ''ğ''Ğ''ş''Ş''ü''Ü'\s\d]{1,50}$
And it works for all the special characters I included except for the ‘–‘. It just doesn’t work. I tried Internet Explorer and Firefox, same problem. How can it be fixed?
Why all the single quotes? They are unnecessary.
^[-a-zA-Z_/\\@&.,çÇöÖIiiIgGsSüÜ\s\d]{1,50}$ ^ ^^Move the ‘-‘ to the start or the end of the character class to have it recognized. Also, the backslash needs to be escaped properly, or you won’t be able to match backslashes either.
See the ‘^’ marks above.