views:

520

answers:

7

How do I match a digit in Visual Studio? My first guess: \d is not working for me. I s there a list of special characters in visual studio?

+1  A: 

Have you tried [0-9]?

dirkgently
+1  A: 

Well, assuming you just need to match literally numbers, you could use a range like [0-9]+

EvanK
+1  A: 

There's a little drop down to the right of the find box that will show you the regular expression notation used in the VS find utility. It's the big arrow pointing to the right.

You can use :z for digits (and make sure you have the regex checkbox checked :).

Mike
+1  A: 

MSDN says that its :d

cube
Correct answer!
Cerebrus
+2  A: 

According to the MSDN docs for Visual Studio's regular expressions, it's :d.

There's also :z which matches one or more digits, i.e. used to match an integer.

And yes, VS regexes are bizarre.

Jon Skeet
Thanks again Jon! Exactly what I was looking for.
Bryan
+4  A: 
Jose Basilio
That's only a partial list. From the docs: "The list of all regular expressions that are valid in Find and Replace operations is longer than can be displayed in the Expression Builder." In particular, that doesn't show :d for digit...
Jon Skeet
The screenshot is very helpful. Thank you.
Bryan
A: 

Download Expresso - It is a good GUI tool for learning - trying regexes ( has C# support with code generation). Here is a link to a table with the VS regex rools

YordanGeorgiev