Reputation: 17581
How do I match a digit in Visual Studio?
My first guess is \d
, but it is not working for me.
Second, is there a list of special characters in Visual Studio?
Upvotes: 4
Views: 3312
Reputation: 51528
Here are the Regular Expressions that it recognizes. Read this great article on the Visual Studio Regular Expressions by Jeff Atwood.
(source: codinghorror.com)
Upvotes: 4
Reputation: 31614
How to match a digit depends on the version of Visual Studio1:
\d
will work in Visual Studio 2012 and later. These versions of Visual Studio uses the same syntax as .NET Framework regular expressions.
:d
will work in Visual Studio 2010 and earlier (Visual Studio .NET 2003, Visual Studio .NET (2002), Visual Studio 2005, Visual Studio 2008, and Visual Studio 2010)
As for the second question, there is a list of special characters in Using Regular Expressions in Visual Studio (for both the new and old syntax).
1 Using Regular Expressions in Visual Studio (MSDN)
Upvotes: 0
Reputation: 3948
Regular Expressions (Visual Studio), Visual Studio 2005 (MSDN) states that it's :d
.
Upvotes: 1
Reputation: 1502536
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.
Upvotes: 3
Reputation: 4600
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 :).
Upvotes: 1
Reputation: 1072
Well, assuming you just need to match literally numbers, you could use a range like [0-9]+
Upvotes: 2