CINXE.COM

Using Regular Expressions with .NET - C# and Visual Basic

<!DOCTYPE html> <html lang="en"><head><meta charset="utf-8"><link rel=canonical href='https://https://www.regular-expressions.info//dotnet.html'><title>Using Regular Expressions with .NET - C# and Visual Basic</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="author" content="Jan Goyvaerts"> <meta name="description" content="Learn how to use the regular expression classes that are part of the Microsoft .NET (dot net) Framework, and can be readily used in any .NET programming language such as C# (C sharp) or Visual Basic.NET"> <meta name="keywords" content=""> <link rel=stylesheet href="regex.css" type="text/css"><script src="theme.js" type="text/javascript"></script><link rel="alternate" type="application/rss+xml" title="New at Regular-Expressions.info" href="updates.xml"> </head> <body bgcolor=white text=black> <div id=top></div> <div id=btntop><div id=btngrid><a href="quickstart.html" target="_top"><div>Quick&nbsp;Start</div></a><a href="tutorial.html" target="_top"><div>Tutorial</div></a><a href="tools.html" target="_top"><div>Tools&nbsp;&amp;&nbsp;Languages</div></a><a href="examples.html" target="_top"><div>Examples</div></a><a href="refflavors.html" target="_top"><div>Reference</div></a><a href="books.html" target="_top"><div>Book&nbsp;Reviews</div></a></div></div> <div id=contents><div id=side> <TABLE CLASS=side CELLSPACING=0 CELLPADDING=4><TR><TD CLASS=sideheader>Regex Tools</TD></TR><TR><TD><A HREF="grep.html" TARGET=_top>grep</A></TD></TR><TR><TD><A HREF="powergrep.html" TARGET=_top>PowerGREP</A></TD></TR><TR><TD><A HREF="regexbuddy.html" TARGET=_top>RegexBuddy</A></TD></TR><TR><TD><A HREF="regexmagic.html" TARGET=_top>RegexMagic</A></TD></TR> </TABLE><TABLE CLASS=side CELLSPACING=0 CELLPADDING=4><TR><TD CLASS=sideheader>General Applications</TD></TR><TR><TD><A HREF="editpadlite.html" TARGET=_top>EditPad Lite</A></TD></TR><TR><TD><A HREF="editpadpro.html" TARGET=_top>EditPad Pro</A></TD></TR> </TABLE><TABLE CLASS=side CELLSPACING=0 CELLPADDING=4><TR><TD CLASS=sideheader>Languages &amp; Libraries</TD></TR><TR><TD><A HREF="boost.html" TARGET=_top>Boost</A></TD></TR><TR><TD><A HREF="delphi.html" TARGET=_top>Delphi</A></TD></TR><TR><TD><A HREF="gnu.html" TARGET=_top>GNU (Linux)</A></TD></TR><TR><TD><A HREF="groovy.html" TARGET=_top>Groovy</A></TD></TR><TR><TD><A HREF="java.html" TARGET=_top>Java</A></TD></TR><TR><TD><A HREF="javascript.html" TARGET=_top>JavaScript</A></TD></TR><TR><TD><A HREF="dotnet.html" TARGET=_top>.NET</A></TD></TR><TR><TD><A HREF="pcre.html" TARGET=_top>PCRE (C/C++)</A></TD></TR><TR><TD><A HREF="pcre2.html" TARGET=_top>PCRE2 (C/C++)</A></TD></TR><TR><TD><A HREF="perl.html" TARGET=_top>Perl</A></TD></TR><TR><TD><A HREF="php.html" TARGET=_top>PHP</A></TD></TR><TR><TD><A HREF="posix.html" TARGET=_top>POSIX</A></TD></TR><TR><TD><A HREF="powershell.html" TARGET=_top>PowerShell</A></TD></TR><TR><TD><A HREF="python.html" TARGET=_top>Python</A></TD></TR><TR><TD><A HREF="rlanguage.html" TARGET=_top>R</A></TD></TR><TR><TD><A HREF="ruby.html" TARGET=_top>Ruby</A></TD></TR><TR><TD><A HREF="stdregex.html" TARGET=_top>std::regex</A></TD></TR><TR><TD><A HREF="tcl.html" TARGET=_top>Tcl</A></TD></TR><TR><TD><A HREF="vbscript.html" TARGET=_top>VBScript</A></TD></TR><TR><TD><A HREF="vb.html" TARGET=_top>Visual Basic 6</A></TD></TR><TR><TD><A HREF="wxwidgets.html" TARGET=_top>wxWidgets</A></TD></TR><TR><TD><A HREF="xml.html" TARGET=_top>XML Schema</A></TD></TR><TR><TD><A HREF="realbasic.html" TARGET=_top>Xojo</A></TD></TR><TR><TD><A HREF="xpath.html" TARGET=_top>XQuery &amp; XPath</A></TD></TR><TR><TD><A HREF="xregexp.html" TARGET=_top>XRegExp</A></TD></TR> </TABLE><TABLE CLASS=side CELLSPACING=0 CELLPADDING=4><TR><TD CLASS=sideheader>Databases</TD></TR><TR><TD><A HREF="mysql.html" TARGET=_top>MySQL</A></TD></TR><TR><TD><A HREF="oracle.html" TARGET=_top>Oracle</A></TD></TR><TR><TD><A HREF="postgresql.html" TARGET=_top>PostgreSQL</A></TD></TR> </TABLE><TABLE CLASS=side CELLSPACING=0 CELLPADDING=4><TR><TD CLASS=sideheader>More on This Site</TD></TR><TR><TD><A HREF="index.html" TARGET=_top>Introduction</A></TD></TR><TR><TD><A HREF="quickstart.html" TARGET=_top>Regular Expressions Quick Start</A></TD></TR><TR><TD><A HREF="tutorial.html" TARGET=_top>Regular Expressions Tutorial</A></TD></TR><TR><TD><A HREF="replacetutorial.html" TARGET=_top>Replacement Strings Tutorial</A></TD></TR><TR><TD><A HREF="tools.html" TARGET=_top>Applications and Languages</A></TD></TR><TR><TD><A HREF="examples.html" TARGET=_top>Regular Expressions Examples</A></TD></TR><TR><TD><A HREF="refflavors.html" TARGET=_top>Regular Expressions Reference</A></TD></TR><TR><TD><A HREF="refreplace.html" TARGET=_top>Replacement Strings Reference</A></TD></TR><TR><TD><A HREF="books.html" TARGET=_top>Book Reviews</A></TD></TR><TR><TD><A HREF="print.html" TARGET=_top>Printable PDF</A></TD></TR><TR><TD><A HREF="about.html" TARGET=_top>About This Site</A></TD></TR><TR><TD><A HREF="updates.html" TARGET=_top>RSS Feed &amp; Blog</A></TD></TR></TABLE></DIV><div class=bodytext><div class=topad><A HREF="https://www.regexbuddy.com/dotnet.html" TARGET="_top"><picture><source media="(max-width: 370px)" srcset="ads/320/rxbdotnet100.png 1x, ads/320/rxbdotnet150.png 1.5x, ads/320/rxbdotnet200.png 2x, ads/320/rxbdotnet250.png 2.5x, ads/320/rxbdotnet300.png 3x, ads/320/rxbdotnet350.png 3.5x, ads/320/rxbdotnet400.png 4x"><source media="(max-width: 500px)" srcset="ads/360/rxbdotnet100.png 1x, ads/360/rxbdotnet150.png 1.5x, ads/360/rxbdotnet200.png 2x, ads/360/rxbdotnet250.png 2.5x, ads/360/rxbdotnet300.png 3x, ads/360/rxbdotnet350.png 3.5x, ads/360/rxbdotnet400.png 4x"><source media="(max-width: 660px)" srcset="ads/480/rxbdotnet100.png 1x, ads/480/rxbdotnet150.png 1.5x, ads/480/rxbdotnet200.png 2x, ads/480/rxbdotnet250.png 2.5x, ads/480/rxbdotnet300.png 3x, ads/480/rxbdotnet350.png 3.5x, ads/480/rxbdotnet400.png 4x"><source media="(max-width: 747px)" srcset="ads/640/rxbdotnet100.png 1x, ads/640/rxbdotnet150.png 1.5x, ads/640/rxbdotnet200.png 2x, ads/640/rxbdotnet250.png 2.5x, ads/640/rxbdotnet300.png 3x, ads/640/rxbdotnet350.png 3.5x, ads/640/rxbdotnet400.png 4x"><img src="ads/728/rxbdotnet100.png" srcset="ads/728/rxbdotnet100.png 1x, ads/728/rxbdotnet125.png 1.25x, ads/728/rxbdotnet150.png 1.5x, ads/728/rxbdotnet175.png 1.75x, ads/728/rxbdotnet200.png 2x, ads/728/rxbdotnet250.png 2.5x, ads/728/rxbdotnet300.png 3x, ads/728/rxbdotnet350.png 3.5x, ads/728/rxbdotnet400.png 4x" alt="RegexBuddy—The best regex editor and tester for .NET developers!"></picture></A></div> <div class=bulb><h1>Using Regular Expressions with Microsoft .NET</h1><script type="text/javascript">showbulb();</script></div> <p>Microsoft .NET, which you can use with any .NET programming language such as C# (C sharp) or Visual Basic.NET, has solid support for regular expressions. .NET’s regex flavor is very feature-rich. The only noteworthy features that are lacking are <A HREF="possessive.html" TARGET="_top">possessive quantifiers</A> and <A HREF="subroutine.html" TARGET="_top">subroutine calls</A>.</p> <p>There are no differences in the regex flavor supported by the .NET Framework versions 2.0 through 4.8. There are no differences between this flavor and the flavor supported by any version of .NET Core either. That includes the original .NET Core 1.0.0 and the latest .NET 5.0.</p> <p>There are a few differences between the regex flavor in the .NET Framework 1.x compared with later versions. The .NET Framework 2.0 fixes a few bugs. The <a href="unicode.html#category">Unicode categories</a> <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Pi}</SPAN></TT> and <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Pf}</SPAN></TT> are no longer reversed. <a href="unicode.html#block">Unicode blocks</a> with hyphens in their names are now handled correctly. One feature was added in .NET 2.0: <A HREF="charclasssubtract.html" TARGET="_top">character class subtraction</A>. It works exactly the way it does in <A HREF="xml.html" TARGET="_top">XML Schema regular expressions</A>. The XML Schema standard first defined this feature and its syntax.</p> <h2>System.Text.RegularExpressions Overview (Using VB.NET Syntax)</h2> <p>The regex classes are located in the namespace System.Text.RegularExpressions. To make them available, place <tt class=code>Imports System.Text.RegularExpressions</tt> at the start of your source code.</p> <p>The <tt class=code>Regex</tt> class is the one you use to compile a regular expression. For efficiency, regular expressions are compiled into an internal format. If you plan to use the same regular expression repeatedly, construct a <tt class=code>Regex</tt> object as follows: <tt class=code>Dim RegexObj as Regex = New Regex(&quot;regularexpression&quot;)</tt>. You can then call <tt class=code>RegexObj.IsMatch(&quot;subject&quot;)</tt> to check whether the regular expression matches the subject string. The <tt class=code>Regex</tt> allows an optional second parameter of type <tt class=code>RegexOptions</tt>. You could specify <tt class=code>RegexOptions.IgnoreCase</tt> as the final parameter to make the regex case insensitive. Other options are <tt class=code>IgnorePatternWhitespace</tt> which makes the regex <A HREF="freespacing.html" TARGET="_top">free-spacing</A>, <tt class=code>RegexOptions.Singleline</tt> which makes the <A HREF="dot.html" TARGET="_top">dot to match newlines</A>, <tt class=code>RegexOptions.Multiline</tt> which makes the <A HREF="anchors.html" TARGET="_top">caret and dollar to match at embedded newlines</A> in the subject string, and <tt class=code>RegexOptions.ExplicitCapture</tt> which <a href="named.html#number">turns all unnamed groups into non-capturing groups</a>.</p> <p>Call <tt class=code>RegexObj.Replace(&quot;subject&quot;, &quot;replacement&quot;)</tt> to perform a search-and-replace using the regex on the subject string, replacing all matches with the replacement string. In the replacement string, you can use <TT CLASS=syntax><SPAN CLASS="regexspecial">$&amp;</SPAN></TT> to insert the entire regex match into the replacement text. You can use <TT CLASS=syntax><SPAN CLASS="regexspecial">$1</SPAN></TT>, <TT CLASS=syntax><SPAN CLASS="regexspecial">$2</SPAN></TT>, <TT CLASS=syntax><SPAN CLASS="regexspecial">$3</SPAN></TT>, etc. to insert the text matched between <A HREF="brackets.html" TARGET="_top">capturing parentheses</A> into the replacement text. Use <TT CLASS=syntax><SPAN CLASS="regexescaped">$$</SPAN></TT> to insert a single dollar sign into the replacement text. To replace with the first backreference immediately followed by the digit 9, use <TT CLASS=syntax><SPAN CLASS="regexspecial">${1}</SPAN><SPAN CLASS="replaceplain">9</SPAN></TT>. If you type $19, and there are less than 19 backreferences, then <TT CLASS=syntax><SPAN CLASS="regexspecial">$19</SPAN></TT> will be interpreted as literal text, and appear in the result string as such. To insert the text from a <A HREF="named.html" TARGET="_top">named capturing group</A>, use <TT CLASS=syntax><SPAN CLASS="regexspecial">${name}</SPAN></TT>. Improper use of the $ sign may produce an undesirable result string, but will never cause an exception to be raised.</p> <p><tt class=code>RegexObj.Split(&quot;Subject&quot;)</tt> splits the subject string along regex matches, returning an array of strings. The array contains the text between the regex matches. If the regex contains <A HREF="brackets.html" TARGET="_top">capturing parentheses</A>, the text matched by them is also included in the array. If you want the entire regex matches to be included in the array, simply place parentheses around the entire regular expression when instantiating <tt class=code>RegexObj</tt>.</p> <p>The <tt class=code>Regex</tt> class also contains several static methods that allow you to use regular expressions without instantiating a <tt class=code>Regex</tt> object. This reduces the amount of code you have to write, and is appropriate if the same regular expression is used only once or reused seldomly. Note that member overloading is used a lot in the <tt class=code>Regex</tt> class. All the static methods have the same names (but different parameter lists) as other non-static methods.</p> <p><tt class=code>Regex.IsMatch(&quot;subject&quot;, &quot;regex&quot;)</tt> checks if the regular expression matches the subject string. <tt class=code>Regex.Replace(&quot;subject&quot;, &quot;regex&quot;, &quot;replacement&quot;)</tt> performs a search-and-replace. <tt class=code>Regex.Split(&quot;subject&quot;, &quot;regex&quot;)</tt> splits the subject string into an array of strings as described above. All these methods accept an optional additional parameter of type <tt class=code>RegexOptions</tt>, like the constructor.</p> <h2>The System.Text.RegularExpressions.Match Class</h2> <p>If you want more information about the regex match, call <tt class=code>Regex.Match()</tt> to construct a <tt class=code>Match</tt> object. If you instantiated a <tt class=code>Regex</tt> object, use <tt class=code>Dim MatchObj as Match = RegexObj.Match(&quot;subject&quot;)</tt>. If not, use the static version: <tt class=code>Dim MatchObj as Match = Regex.Match(&quot;subject&quot;, &quot;regex&quot;)</tt>.</p> <p>Either way, you will get an object of class <tt class=code>Match</tt> that holds the details about the first regex match in the subject string. <tt class=code>MatchObj.Success</tt> indicates if there actually was a match. If so, use <tt class=code>MatchObj.Value</tt> to get the contents of the match, <tt class=code>MatchObj.Length</tt> for the length of the match, and <tt class=code>MatchObj.Index</tt> for the start of the match in the subject string. The start of the match is zero-based, so it effectively counts the number of characters in the subject string to the left of the match.</p> <p>If the regular expression contains <A HREF="brackets.html" TARGET="_top">capturing parentheses</A>, use the <tt class=code>MatchObj.Groups</tt> collection. <tt class=code>MatchObj.Groups.Count</tt> indicates the number of capturing parentheses. The count includes the zeroth group, which is the entire regex match. <tt class=code>MatchObj.Groups(3).Value</tt> gets the text matched by the third pair of parentheses. <tt class=code>MatchObj.Groups(3).Length</tt> and <tt class=code>MatchObj.Groups(3).Index</tt> get the length of the text matched by the group and its index in the subject string, relative to the start of the subject string. <tt class=code>MatchObj.Groups(&quot;name&quot;)</tt> gets the details of the <A HREF="named.html" TARGET="_top">named group</A> “name”. </p> <p>To find the next match of the regular expression in the same subject string, call <tt class=code>MatchObj.NextMatch()</tt> which returns a new <tt class=code>Match</tt> object containing the results for the second match attempt. You can continue calling <tt class=code>MatchObj.NextMatch()</tt> until <tt class=code>MatchObj.Success</tt> is False.</p> <p>Note that after calling <tt class=code>RegexObj.Match()</tt>, the resulting <tt class=code>Match</tt> object is independent from <tt class=code>RegexObj</tt>. This means you can work with several <tt class=code>Match</tt> objects created by the same <tt class=code>Regex</tt> object simultaneously.</p> <h2>Regular Expressions, Literal Strings and Backslashes</h2> <p>In literal C# strings, as well as in C++ and many other .NET languages, the backslash is an escape character. The literal string <tt class=code>&quot;\\&quot;</tt> is a single backslash. In regular expressions, the backslash is also an escape character. The regular expression <TT CLASS=syntax><SPAN CLASS="regexescaped">\\</SPAN></TT> matches a single backslash. This regular expression as a C# string, becomes <tt class=code>&quot;\\\\&quot;</tt>. That’s right: 4 backslashes to match a single one.</p> <p>The regex <TT CLASS=syntax><SPAN CLASS="regexspecial">\w</SPAN></TT> matches a word character. As a C# string, this is written as <tt class=code>&quot;\\w&quot;</tt>.</p> <p>To make your code more readable, you should use C# verbatim strings. In a verbatim string, a backslash is an ordinary character. This allows you to write the regular expression in your C# code as you would write it a tool like <A HREF="regexbuddy.html" TARGET="_top">RegexBuddy</A> or <A HREF="powergrep.html" TARGET="_top">PowerGREP</A>, or as the user would type it into your application. The regex to match a backlash is written as <tt class=code>@&quot;\\&quot;</tt> when using C# verbatim strings. The backslash is still an escape character in the regular expression, so you still need to double it. But doubling is better than quadrupling. To match a word character, use the verbatim string <tt class=code>@&quot;\w&quot;</tt>.</p> <a name="ecmascript"></a><h2>RegexOptions.ECMAScript</h2> <p>Passing <tt>RegexOptions.ECMAScript</tt> to the <tt>Regex()</tt> constructor changes the behavior of certain regex features to follow the behavior prescribed in the <A HREF="javascript.html" TARGET="_top">ECMA-262</A> standard. This standard defines the <A HREF="javascript.html" TARGET="_top">ECMAScript</A> language, which is better known as <A HREF="javascript.html" TARGET="_top">JavaScript</A>. The table below compares the differences between canonical .NET (without the ECMAScript option) and .NET in ECMAScirpt mode. For reference the table also compares how JavaScript in modern browsers behaves in these areas.</p> <table class=reference> <tr><th>Feature or Syntax</th><th>Canonical .NET</th><th>.NET in ECMAScript&nbsp;mode</th><th>JavaScript</th></tr> <tr><td>RegexOptions.FreeSpacing</td><td>Supported</td><td>Only via <TT CLASS=syntax><SPAN CLASS="regexmeta">(?</SPAN><SPAN CLASS="regexmeta">x</SPAN><SPAN CLASS="regexmeta">)</SPAN></TT></td><td>Not supported</td></tr> <tr><td>RegexOptions.SingleLine</td><td>Supported</td><td>Only via <TT CLASS=syntax><SPAN CLASS="regexmeta">(?</SPAN><SPAN CLASS="regexmeta">s</SPAN><SPAN CLASS="regexmeta">)</SPAN></TT></td><td>Not supported</td></tr> <tr><td>RegexOptions.ExplicitCapture</td><td>Supported</td><td>Only via <TT CLASS=syntax><SPAN CLASS="regexmeta">(?</SPAN><SPAN CLASS="regexmeta">n</SPAN><SPAN CLASS="regexmeta">)</SPAN></TT></td><td>Not supported</td></tr> <tr><td>Escaped letter or underscore that does not form a regex token</td><td>Error</td><td colspan=2 align=center>Literal letter or underscore</td></tr> <tr><td>Escaped digit that is not a valid backreference</td><td>Error</td><td colspan=2 align=center>Octal escape or literal 8 or 9</td></tr> <tr><td>Escaped double digits that do not form a valid backreference</td><td>Error</td><td colspan=2 align=center>Single digit backreference and literal digit if the single digit backreference is valid; otherwise single or double digit octal escape and/or literal 8 and 9</td></tr> <tr><td>Backreference to non-participating group</td><td>Fails to match</td><td colspan=2 align=center>Zero-length match</td></tr> <tr><td>Forward reference</td><td>Supported</td><td>Error</td><td>Zero-length match</td></tr> <tr><td>Backreference to group 0</td><td>Fails to match</td><td>Zero-length match</td><td>Syntactically not possible</td></tr> <tr><td><TT CLASS=syntax><SPAN CLASS="regexspecial">\s</SPAN></TT></td><td>Unicode</td><td>ASCII</td><td>Unicode</td></tr> <tr><td><TT CLASS=syntax><SPAN CLASS="regexspecial">\d</SPAN></TT></td><td>Unicode</td><td colspan=2 align=center>ASCII</td></tr> <tr><td><TT CLASS=syntax><SPAN CLASS="regexspecial">\w</SPAN></TT></td><td>Unicode</td><td colspan=2 align=center>ASCII</td></tr> <tr><td><TT CLASS=syntax><SPAN CLASS="regexspecial">\b</SPAN></TT></td><td>Unicode</td><td colspan=2 align=center>ASCII</td></tr> </table> <p>Though <tt>RegexOptions.ECMAScript</tt> brings the .NET regex engine a little bit closer to JavaScript’s, there are still significant differences between the .NET regex flavor and the JavaScript regex flavor. When creating web pages using ASP.NET on the server an JavaScript on the client, you cannot assume the same regex to work in the same way both on the client side and the server side even when setting <tt>RegexOptions.ECMAScript</tt>. The next table lists the more important differences between .NET and JavaScript. RegexOptions.ECMAScript has no impact on any of these.</p> <p>The table also compares the <A HREF="xregexp.html" TARGET="_top">XRegExp</A> library for JavaScript. You can use this library to bring JavaScript’s regex flavor a little bit closer to .NET’s.</p> <table class=reference> <tr><th>Feature or syntax</th><th>.NET</th><th>XRegExp</th><th>JavaScript</th></tr> <tr><td><a name="dot.html">Dot</a></td><td><TT CLASS=syntax><SPAN CLASS="regexccopen">[</SPAN><SPAN CLASS="regexccspecial">^</SPAN><SPAN CLASS="regexccspecial">\n</SPAN><SPAN CLASS="regexccopen">]</SPAN></TT></td><td colspan=2 align=center><TT CLASS=syntax><SPAN CLASS="regexccopen">[</SPAN><SPAN CLASS="regexccspecial">^</SPAN><SPAN CLASS="regexccspecial">\n</SPAN><SPAN CLASS="regexccspecial">\r</SPAN><SPAN CLASS="regexccspecial">\u2028</SPAN><SPAN CLASS="regexccspecial">\u2029</SPAN><SPAN CLASS="regexccopen">]</SPAN></TT></td></tr> <tr><td><a name="anchors.html#multi">Anchors in multi-line mode</a></td><td>Treat only <TT CLASS=syntax><SPAN CLASS="regexspecial">\n</SPAN></TT> as a line break</td><td colspan=2 align=center>Treat <TT CLASS=syntax><SPAN CLASS="regexspecial">\n</SPAN></TT>, <TT CLASS=syntax><SPAN CLASS="regexspecial">\r</SPAN></TT>, <TT CLASS=syntax><SPAN CLASS="regexspecial">\u2028</SPAN></TT>, and <TT CLASS=syntax><SPAN CLASS="regexspecial">\u2029</SPAN></TT> as line breaks</td></tr> <tr><td><TT CLASS=syntax><SPAN CLASS="regexspecial">$</SPAN></TT> without multi-line mode</td><td>Matches at very end of string</td><td colspan=2 align=center>Matches <a href="anchors.html#realend">before final line break</a> and at very end of string</td></tr> <tr><td><a href="anchors.html#az">Permanent start and end of string anchors</a></td><td>Supported</td><td colspan=2 align=center>Not supported</td></tr> <tr><td>Empty character class</td><td>Syntactically not possible</td><td colspan=2 align=center>Fails to match</td></tr> <tr><td><a href="lookaround.html#lookbehind">Lookbehind</a></td><td>Supported without restrictions</td><td colspan=2 align=center>Supported (without restrictions) since ECMAScript 2018</td></tr> <tr><td><A HREF="modifiers.html" TARGET="_top">Mode modifiers</A></td><td>Anywhere</td><td>At start of regex only</td><td>Not supported</td></tr> <tr><td><a href="freespacing.html#parenscomment">Comments</a></td><td colspan=2 align=center>Supported</td><td>Not supported</td></tr> <tr><td><A HREF="unicode.html" TARGET="_top">Unicode properties</A></td><td colspan=2 align=center>Categories and blocks</td><td>Not supported</td></tr> <tr><td><A HREF="named.html" TARGET="_top">Named capture and backreferences</A></td><td colspan=2 align=center>Supported</td><td>Not supported</td></tr> <tr><td><A HREF="balancing.html" TARGET="_top">Balancing groups</A></td><td>Supported</td><td colspan=2 align=center>Not supported</td></tr> <tr><td><A HREF="conditional.html" TARGET="_top">Conditionals</A></td><td>Supported</td><td colspan=2 align=center>Not supported</td></tr> </table> <h3>Further Reading</h3> <p><A HREF="hipowls.html" TARGET="_top"><img src="books/hipowlssmall.jpg" width=122 height=160 alt="Mastering Regular Expressions" border=0 align=right class=right></A>The book <A HREF="hipowls.html" TARGET="_top">Mastering Regular Expressions</A> not only explains everything you want to know and don’t want to know about regular expressions, including the regex features that are unique to .NET. It has an excellent chapter on .NET’s System.Text.RegularExpressions namespace, explaining the various Regex classes far better than Microsoft’s documentatio, with plenty of example VB.NET example code and some C# code showing more advanced techniques.</p> <p><A HREF="hipowls.html" TARGET="_top">My review of the book Mastering Regular Expressions</A></p> <ul> <li><a href="https://www.amazon.com/exec/obidos/ASIN/0596528124/jgsbookselection">Buy Mastering Regular Expressions from Amazon.com</a></li> <li><a href="https://www.amazon.co.uk/exec/obidos/ASIN/0596528124/jgsbookselect">Buy Mastering Regular Expressions from Amazon.co.uk</a></li> <li><a href="https://www.amazon.fr/exec/obidos/ASIN/0596528124/regularexpres-21">Buy Mastering Regular Expressions from Amazon.fr</a></li> <li><a href="https://www.amazon.de/exec/obidos/ASIN/0596528124/regularexpr0a-21">Buy Mastering Regular Expressions from Amazon.de</a></li> <li><a href="https://www.amazon.de/exec/obidos/ASIN/3897217201/regularexpr0a-21">Buy Reguläre Ausdrücke from Amazon.de</a></li> </ul> <script type="text/javascript"> amzn_assoc_placement = "adunit0"; amzn_assoc_search_bar = "false"; amzn_assoc_tracking_id = "jgsbookselection"; amzn_assoc_ad_mode = "search"; amzn_assoc_ad_type = "smart"; amzn_assoc_marketplace = "amazon"; amzn_assoc_region = "US"; amzn_assoc_title = ""; amzn_assoc_default_search_phrase = ".NET"; amzn_assoc_default_category = "Books"; amzn_assoc_linkid = "356e0933a7c8586330d5e923e6d874ed"; </script> <script src="https://z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script> <div id=cntmobi><p>|&ensp;<a href='quickstart.html'>Quick&nbsp;Start</a>&ensp;|&ensp;<a href='tutorial.html'>Tutorial</a>&ensp;|&ensp;<a href='tools.html'>Tools&nbsp;&amp;&nbsp;Languages</a>&ensp;|&ensp;<a href='examples.html'>Examples</a>&ensp;|&ensp;<a href='refflavors.html'>Reference</a>&ensp;|&ensp;<a href='books.html'>Book&nbsp;Reviews</a>&ensp;|</p><p>|&ensp;<a href='grep.html'>grep</a>&ensp;|&ensp;<a href='powergrep.html'>PowerGREP</a>&ensp;|&ensp;<a href='regexbuddy.html'>RegexBuddy</a>&ensp;|&ensp;<a href='regexmagic.html'>RegexMagic</a>&ensp;|</p><p>|&ensp;<a href='editpadlite.html'>EditPad Lite</a>&ensp;|&ensp;<a href='editpadpro.html'>EditPad Pro</a>&ensp;|</p><p>|&ensp;<a href='boost.html'>Boost</a>&ensp;|&ensp;<a href='delphi.html'>Delphi</a>&ensp;|&ensp;<a href='gnu.html'>GNU (Linux)</a>&ensp;|&ensp;<a href='groovy.html'>Groovy</a>&ensp;|&ensp;<a href='java.html'>Java</a>&ensp;|&ensp;<a href='javascript.html'>JavaScript</a>&ensp;|&ensp;<a href='dotnet.html'>.NET</a>&ensp;|&ensp;<a href='pcre.html'>PCRE (C/C++)</a>&ensp;|&ensp;<a href='pcre2.html'>PCRE2 (C/C++)</a>&ensp;|&ensp;<a href='perl.html'>Perl</a>&ensp;|&ensp;<a href='php.html'>PHP</a>&ensp;|&ensp;<a href='posix.html'>POSIX</a>&ensp;|&ensp;<a href='powershell.html'>PowerShell</a>&ensp;|&ensp;<a href='python.html'>Python</a>&ensp;|&ensp;<a href='rlanguage.html'>R</a>&ensp;|&ensp;<a href='ruby.html'>Ruby</a>&ensp;|&ensp;<a href='stdregex.html'>std::regex</a>&ensp;|&ensp;<a href='tcl.html'>Tcl</a>&ensp;|&ensp;<a href='vbscript.html'>VBScript</a>&ensp;|&ensp;<a href='vb.html'>Visual Basic 6</a>&ensp;|&ensp;<a href='wxwidgets.html'>wxWidgets</a>&ensp;|&ensp;<a href='xml.html'>XML Schema</a>&ensp;|&ensp;<a href='realbasic.html'>Xojo</a>&ensp;|&ensp;<a href='xpath.html'>XQuery &amp; XPath</a>&ensp;|&ensp;<a href='xregexp.html'>XRegExp</a>&ensp;|</p><p>|&ensp;<a href='mysql.html'>MySQL</a>&ensp;|&ensp;<a href='oracle.html'>Oracle</a>&ensp;|&ensp;<a href='postgresql.html'>PostgreSQL</a>&ensp;|</p></div> <div id=copyright> <P CLASS=copyright>Page URL: <A HREF="https://www.regular-expressions.info/dotnet.html" TARGET="_top">https://www.regular-expressions.info/dotnet.html</A><BR> Page last updated: 24 August 2021<BR> Site last updated: 06 November 2024<BR> Copyright &copy; 2003-2024 Jan Goyvaerts. All rights reserved.</P> </div> </div> </div> </body></html>

Pages: 1 2 3 4 5 6 7 8 9 10