regular expression
Regex regex = new Regex( "^\d+$");
this code gives an error pointing \d .
error message is "invalid escape character" , but in fact \d is not escap character , \d means 0 to 9 digits.
how can i fix this
thnx
Regex regex = new Regex( "^\d+$");
this code gives an error pointing \d .
error message is "invalid escape character" , but in fact \d is not escap character , \d means 0 to 9 digits.
how can i fix this
thnx
In a regular expression "\d" means digit. However, the trick is getting that to the regular expression.
To the C# compile, inside a string \d means "escaped-D" (which is meaningless). There are two ways to deal with this:
escape the back-slash: Regex("^\\d+$"); (Escaped-backslash means just backslash)
use a literal string: Regex(@"^\d+$"); (@ means that inside that string nothing has a special meaning (except double-quote))