Visual Studio Regular Expression



The characters included in the Character or sequence column are special regular expression language elements. To match them in a regular expression, they must be escaped or included in a positive character group. For example, the regular expression $d+ or $d+ matches '$1200'. A: Matches a bell (alarm) character, u0007. This sample was built to ease your pain when working with regular expressions. It rehosts the editor in a dialog box and provides a basic language service to provide colorization, brace matching, sample testing grouping and selection tracking.

  • Developer community 2. Search Search Microsoft.com.
  • Browse other questions tagged regex visual-studio-2010 or ask your own question. The Overflow Blog How often do people actually copy and paste from Stack Overflow?

The Visual Studio IDE supports searching and replacing with regular expressions, right? Sure it does. It's right there in grey and black in the find and replace dialog. Just tick the 'use Regular expressions' checkbox and we're off to the races.

However, you're in for an unpleasant surprise when you attempt to actually use regular expressions to find anything in Visual Studio. Apparently the Visual Studio IDE has its own bastardized regular expression syntax. Why? Who knows. Probably for arcane backwards compatibility reasons, although I have no idea why you'd want to perpetually carry forward insanity. Evidently it makes people billionaires, so who am I to judge.

God forbid we all learn one standard* regular expression dialect.

At any rate, some of the Visual Studio IDE regular expressions look awfully similar to standard regex:

Visual Studio IDEStandard
Any single character..
Zero or more**
One or more++
Beginning of line^^
End of line$$
Beginning of word<(no equivalent)
End of word>(no equivalent)
Line breaknn
Any character in set[ ][ ]
Any character not in set[^ ][^ ]
Or||
Escape special char
Tag expression{ }( )
C/C++ identifier:i([a-zA-Z_$][a-zA-Z0-9_$]*)
Quoted string:q(('[^']*')|('[^']*'))
Space or Tab:b[ |t]
Integer:z[0-9]+

But they certainly don't act related when you try to use them. For example, try something simple, like finding '[A-Za-z]+'. That's all occurrences of more than one letter in a row. When I try this via the Visual Studio find dialog with the regex option checked, I get positively bizarre results. It finds a word made up of all letters, true, but as I click 'Find Next', it then finds each subsequent letter in the word. Again. What planet are these so-called 'regular expressions' from?

The semi-abandoned Microsoft VSEditor blog has a three part tutorial (part one, part two, part three) on using the crazy Visual Studio dialect of Regex. There's a lot of emphasis on the strange < and > begin/end word match characters, which have no equivalent that I know of in the .NET and Perl dialect of regular expressions.

You might say that searching with regular expressions is such an extreme edge condition for most developers that it's not worth the Visual Studio development team's time. I won't disagree with you. It is rare, but it's hardly esoteric. Every developer should be able to grok the value of searching with the basic regular expressions that are a staple of their toolkit these days. Heck, some developers are so hard core they search through their code with Lisp expressions. Basic regex search functionality is awfully mild compared to that.

To be honest, searching with regular expressions isn't a common task for me either. But I'd be a lot more likely to use it if I didn't have to perform a lot of mental translation gymnastics on the occasions that I needed it. Don't make me think, man. But there is hope. There's a free add-in available which offers real regular expression searching in Visual Studio.

* well, mostly standard, anyway. Certainly JavaScript regex syntax could be considered standard these days.

Current Version is 1.2.9

See the change log below for more details.

RegEx Explorer is a visual studio addin which lets you create or modify regular expressions and test them with any text. Matches are highlighted by surrounding each with a red box. A dropdown list of suggestions is availabe with choices for email, GUID, URL, etc. Any pattern you create can be added to the suggestion list. Existing suggestions can be removed by pressiong DEL on a selected name.

Checkboxes are available for Ignore Case, Multiline and to auto-add or remove a ^$ wrapper. Patterns can be saved to be future suggestions. Patterns can be copied to the clipboard with a button press for pasting into your code. Matches are displayed in real-time as you type.

Read the README file for more information.

This add-in is offered for free, but donations are welcome (and encouraged!) if you like the utility. Also, please report any issues or make suggestions for changes.

Visual Studio Expression Builder

Visual Studio Regular Expression

Changes in 1.2.9:

Visual Studio Regular Expression

- Allow saved suggestions to start with a number
- Prevent crash on invalid suggestion name

Changes in 1.2.8:

- Added support and VSI for Visual Studio 2010

Changes in 1.2.7:

- Fixed auto update download version

Changes in 1.2.6:

- Fixed issue where vs2005 can't find resource file for icon (use fallback smiley)

Visual Studio Regular Expression

Visual Studio Regular Expression Search

Changes in 1.2.5:

- Fixed intermittent start-up bug
- Made main screen non-modal
- Added help slide out
- Added auto-update check
- Added error popup if start-up fails
- Added Rx icon

Changes in 1.2.4:

- Fixed form tab order
- Fixed version display in About form
- Made window resizable
- Save window location and size
- Add status label for clipboard notification
- Added ability to change textbox font
- Save textbox font setting

Change in 1.2.1:

Visual Studio Regular Expression New Line

- Separated vs 2005 and vs 2008 VSI installers. Please use the appropriate one (or both)

New features in version 1.2:

- Now rather than an MSI the installer is a self-extracting zip containing a VSI installer for VS 2005/2008.

Visual studio regular expression examples

New features in version 1.1:

- Ability to overwrite an existing suggestion with an updated version
- Ability to export and import suggestion (configuration) files to allow sharing of expressions
- Moved configuration file from [AppData]FaustWare!RegExForms to [AppData]FaustWare!RegExExplorer
Retains existing suggestions (configuration)
- Fixed problem with installation of the Addin file on some systems
- Disabled text wrap in the Sample Text box to prevent missing red box on 'wrapped' matches
Also enabled horizontal scroll bar

Here are additional screenshots: