0

I tested a regex using:

 Match match = Regex.Match(txtToMatch.Text,txtRegex.Text,RegexOptions.IgnoreCase);

 if (match.Success) {               
      MessageBox.Show("success");
 }

The regex that was used was /d. However, when I tested it on 9 it returned false. Why is this so?

1
  • thanks. i acidentally added "" around it twice Commented Oct 23, 2012 at 21:31

2 Answers 2

3

I think what you need is \d, rather than /d

Sign up to request clarification or add additional context in comments.

Comments

1

You need to use \d, not /d. To avoid getting your string treated as an escape sequence by C#, you could use a verbatim string: @"\d".

1 Comment

There isn't, but it still gets treated as one, causing an error: "CS1009: Unrecognized escape sequence '\d'".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.