{"id":303,"date":"2011-08-02T12:53:16","date_gmt":"2011-08-02T12:53:16","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=303"},"modified":"2013-05-17T10:35:57","modified_gmt":"2013-05-17T08:35:57","slug":"c-regular-expressions-guide","status":"publish","type":"post","link":"https:\/\/www.extradrm.com\/?p=303","title":{"rendered":"C# Regular Expressions Guide"},"content":{"rendered":"<div>Guide for C# regular expressions metacharacters, operators, quantifiers etc<\/div>\n<p>&nbsp;<\/p>\n<table>\n<tbody>\n<tr valign=\"top\">\n<th width=\"14%\">\n<div align=\"left\">Character<\/div>\n<\/th>\n<th width=\"86%\">Description<\/th>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><\/td>\n<td width=\"86%\">Marks the next character as either a special character or escapes a literal. For example, &#8220;n&#8221; matches the character &#8220;n&#8221;. &#8220;n&#8221; matches a newline character. The sequence &#8220;\\&#8221; matches &#8220;&#8221; and &#8220;(&#8221; matches &#8220;(&#8220;.Note: double quotes may be escaped by doubling them: &#8220;&lt;a href=&#8221;&#8221;&#8230;&gt;&#8221;<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>^ <\/strong><\/td>\n<td width=\"86%\">Depending on whether the MultiLine option is set, matches the position before the first character in a line, or the first character in the string.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>$ <\/strong><\/td>\n<td width=\"86%\">Depending on whether the MultiLine option is set, matches the position after the last character in a line, or the last character in the string.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>* <\/strong><\/td>\n<td width=\"86%\">Matches the preceding character zero or more times. For example, &#8220;zo*&#8221; matches either &#8220;z&#8221; or &#8220;zoo&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>+ <\/strong><\/td>\n<td width=\"86%\">Matches the preceding character one or more times. For example, &#8220;zo+&#8221; matches &#8220;zoo&#8221; but not &#8220;z&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>? <\/strong><\/td>\n<td width=\"86%\">Matches the preceding character zero or one time. For example, &#8220;a?ve?&#8221; matches the &#8220;ve&#8221; in &#8220;never&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>.<\/strong><\/td>\n<td width=\"86%\">Matches any single character except a newline character.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>(pattern) <\/strong><\/td>\n<td width=\"86%\">Matches <em>pattern<\/em> and remembers the match. The matched substring can be retrieved from the resulting <strong>Matches<\/strong> collection, using Item <strong>[0]&#8230;[n]<\/strong>. To match parentheses characters ( ), use &#8220;(&#8221; or &#8220;)&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>(?&lt;name&gt;pattern) <\/strong><\/td>\n<td width=\"86%\">Matches <em>pattern<\/em> and gives the match a name.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>(?:pattern) <\/strong><\/td>\n<td width=\"86%\">A non-capturing group<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>(?=&#8230;) <\/strong><\/td>\n<td width=\"86%\">A positive lookahead<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>(?!&#8230;) <\/strong><\/td>\n<td width=\"86%\">A negative lookahead<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>(?&lt;=&#8230;) <\/strong><\/td>\n<td width=\"86%\">A positive lookbehind .<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>(?&lt;!&#8230;) <\/strong><\/td>\n<td width=\"86%\">A negative lookbehind .<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>x|y<\/strong><\/td>\n<td width=\"86%\">Matches either <em>x<\/em> or <em>y<\/em>. For example, &#8220;z|wood&#8221; matches &#8220;z&#8221; or &#8220;wood&#8221;. &#8220;(z|w)oo&#8221; matches &#8220;zoo&#8221; or &#8220;wood&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>{<em>n<\/em>}<\/strong><\/td>\n<td width=\"86%\"><em>n<\/em> is a non-negative integer. Matches exactly <em>n<\/em> times. For example, &#8220;o{2}&#8221; does not match the &#8220;o&#8221; in &#8220;Bob,&#8221; but matches the first two o&#8217;s in &#8220;foooood&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>{<em>n<\/em>,} <\/strong><\/td>\n<td width=\"86%\"><em>n<\/em> is a non-negative integer. Matches at least <em>n<\/em> times. For example, &#8220;o{2,}&#8221; does not match the &#8220;o&#8221; in &#8220;Bob&#8221; and matches all the o&#8217;s in &#8220;foooood.&#8221; &#8220;o{1,}&#8221; is equivalent to &#8220;o+&#8221;. &#8220;o{0,}&#8221; is equivalent to &#8220;o*&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>{<\/strong><em>n<\/em><strong>,<\/strong><em>m<\/em><strong>}<\/strong><\/td>\n<td width=\"86%\"><em>m<\/em> and <em>n<\/em> are non-negative integers. Matches at least <em>n<\/em> and at most <em>m<\/em> times. For example, &#8220;o{1,3}&#8221; matches the first three o&#8217;s in &#8220;fooooood.&#8221; &#8220;o{0,1}&#8221; is equivalent to &#8220;o?&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>[<\/strong><em>xyz<\/em><strong>]<\/strong><\/td>\n<td width=\"86%\">A character set. Matches any one of the enclosed characters. For example, &#8220;[abc]&#8221; matches the &#8220;a&#8221; in &#8220;plain&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>[^<\/strong><em>xyz<\/em><strong>]<\/strong><\/td>\n<td width=\"86%\">A negative character set. Matches any character not enclosed. For example, &#8220;[^abc]&#8221; matches the &#8220;p&#8221; in &#8220;plain&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>[<\/strong><em>a-z<\/em><strong>]<\/strong><\/td>\n<td width=\"86%\">A range of characters. Matches any character in the specified range. For example, &#8220;[a-z]&#8221; matches any lowercase alphabetic character in the range &#8220;a&#8221; through &#8220;z&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>[^<\/strong><em>m-z<\/em><strong>]<\/strong><\/td>\n<td width=\"86%\">A negative range characters. Matches any character not in the specified range. For example, &#8220;[m-z]&#8221; matches any character not in the range &#8220;m&#8221; through &#8220;z&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>b <\/strong><\/td>\n<td width=\"86%\">Matches a word boundary, that is, the position between a word and a space. For example, &#8220;erb&#8221; matches the &#8220;er&#8221; in &#8220;never&#8221; but not the &#8220;er&#8221; in &#8220;verb&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>B <\/strong><\/td>\n<td width=\"86%\">Matches a non-word boundary. &#8220;ea*rB&#8221; matches the &#8220;ear&#8221; in &#8220;never early&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>d <\/strong><\/td>\n<td width=\"86%\">Matches a digit character. Equivalent to [0-9].<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>D <\/strong><\/td>\n<td width=\"86%\">Matches a non-digit character. Equivalent to [^0-9].<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>f <\/strong><\/td>\n<td width=\"86%\">Matches a form-feed character.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><strong>k <\/strong><\/td>\n<td>A back-reference to a named group.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><strong>n <\/strong><\/td>\n<td>Matches a newline character.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>r <\/strong><\/td>\n<td width=\"86%\">Matches a carriage return character.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>s <\/strong><\/td>\n<td width=\"86%\">Matches any white space including space, tab, form-feed, etc. Equivalent to &#8220;[\u00a0fnrtv]&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>S <\/strong><\/td>\n<td width=\"86%\">Matches any nonwhite space character. Equivalent to &#8220;[^\u00a0fnrtv]&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>t <\/strong><\/td>\n<td width=\"86%\">Matches a tab character.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>v <\/strong><\/td>\n<td width=\"86%\">Matches a vertical tab character.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>w <\/strong><\/td>\n<td width=\"86%\">Matches any word character including underscore. Equivalent to &#8220;[A-Za-z0-9_]&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>W <\/strong><\/td>\n<td width=\"86%\">Matches any non-word character. Equivalent to &#8220;[^A-Za-z0-9_]&#8221;.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>num <\/strong><\/td>\n<td width=\"86%\">Matches <em>num<\/em>, where <em>num<\/em> is a positive integer. A reference back to remembered matches. For example, &#8220;(.)1&#8221; matches two consecutive identical characters.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong><em>n<\/em><\/strong><\/td>\n<td width=\"86%\">Matches <em>n<\/em>, where <em>n<\/em> is an octal escape value. Octal escape values must be 1, 2, or 3 digits long. For example, &#8220;11&#8221; and &#8220;\ufffd11&#8221; both match a tab character. &#8220;\ufffd011&#8221; is the equivalent of &#8220;\ufffd01&#8221; &amp; &#8220;1&#8221;. Octal escape values must not exceed 256. If they do, only the first two digits comprise the expression. Allows ASCII codes to be used in regular expressions.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>x<em>n<\/em><\/strong><\/td>\n<td width=\"86%\">Matches <em>n<\/em>, where <em>n<\/em> is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For example, &#8220;x41&#8221; matches &#8220;A&#8221;. &#8220;x041&#8221; is equivalent to &#8220;x04&#8221; &amp; &#8220;1&#8221;. Allows ASCII codes to be used in regular expressions.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td width=\"14%\"><strong>u<em>n<\/em><\/strong><\/td>\n<td width=\"86%\">Matches a Unicode character expressed in hexadecimal notation with exactly four numeric digits. &#8220;u0200&#8221; matches a space character.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><strong>A<\/strong><\/td>\n<td>Matches the position before the first character in a string. Not affected by the MultiLine setting<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><strong>Z<\/strong><\/td>\n<td>Matches the position after the last character of a string. Not affected by the MultiLine setting.<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td><strong>G<\/strong><\/td>\n<td>Specifies that the matches must be consecutive, without any intervening non-matching characters.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Guide for C# regular expressions metacharacters, operators, quantifiers etc &nbsp; Character Description Marks the next character as either a special character or escapes a literal. For example, &#8220;n&#8221; matches the character &#8220;n&#8221;. &#8220;n&#8221; matches&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2850,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[22],"tags":[140,141,142],"youtube_video":null,"_links":{"self":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/303"}],"collection":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=303"}],"version-history":[{"count":0,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/303\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2850"}],"wp:attachment":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}