Bryan
Bryan

Reputation: 17581

Match a digit in Visual Studio with regular expressions

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

Answers (7)

Jose Basilio
Jose Basilio

Reputation: 51528

Here are the Regular Expressions that it recognizes. Read this great article on the Visual Studio Regular Expressions by Jeff Atwood.

alt text
(source: codinghorror.com)

Upvotes: 4

Peter Mortensen
Peter Mortensen

Reputation: 31614

How to match a digit depends on the version of Visual Studio1:

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

cube
cube

Reputation: 3948

Regular Expressions (Visual Studio), Visual Studio 2005 (MSDN) states that it's :d.

Upvotes: 1

dirkgently
dirkgently

Reputation: 111220

It may work if you try [0-9].

Upvotes: 2

Jon Skeet
Jon Skeet

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

Mike
Mike

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

EvanK
EvanK

Reputation: 1072

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

Upvotes: 2

Related Questions