{"id":870,"date":"2020-08-24T13:54:02","date_gmt":"2020-08-24T14:54:02","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=870"},"modified":"2020-08-24T13:54:02","modified_gmt":"2020-08-24T14:54:02","slug":"table-of-regular-expressions-and-metacharacters","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=870","title":{"rendered":"Table of Regular Expressions and Metacharacters"},"content":{"rendered":"\n<p>Table of metacharacters<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Character<\/th><th>Description<\/th><\/tr><tr><td>\\<\/td><td>Marks the next character as either a special character, a literal, a backreference, or an octal escape. For example, &#8216;n&#8217; matches the character &#8220;n&#8221;. &#8216;\\n&#8217; matches a newline character. The sequence &#8216;\\\\&#8217; matches &#8220;\\&#8221; and &#8220;\\(&#8221; matches &#8220;(&#8220;.<\/td><\/tr><tr><td>^<\/td><td>Matches the position at the beginning of the input string.<\/td><\/tr><tr><td>$<\/td><td>Matches the position at the end of the input string.<\/td><\/tr><tr><td>*<\/td><td>Matches the preceding subexpression zero or more times. For example, zo* matches &#8220;z&#8221; and &#8220;zoo&#8221;. Also, &#8216;(food)*&#8217; matches &#8216;food&#8217;, &#8216;foodfood&#8217;, &#8216;foodfoodfood&#8217; and so on.<br>* is equivalent to {0,}.<\/td><\/tr><tr><td>+<\/td><td>Matches the preceding subexpression one or more times. For example, &#8216;zo+&#8217; matches &#8220;zo&#8221; and &#8220;zoo&#8221;, but not &#8220;z&#8221;.<br>+ is equivalent to {1,}.<\/td><\/tr><tr><td>?<\/td><td>Matches the preceding subexpression zero or one time. For example, &#8220;do(es)?&#8221; matches the &#8220;do&#8221; in &#8220;do&#8221; or &#8220;does&#8221;.<br>? is equivalent to {0,1}<\/td><\/tr><tr><td>{n}<\/td><td>n is a nonnegative integer. Matches exactly n times. For example, &#8216;o{2}&#8217; does not match the &#8216;o&#8217; in &#8220;Bob,&#8221; but matches the two o&#8217;s in &#8220;food&#8221;.<\/td><\/tr><tr><td>{n,}<\/td><td>n is a nonnegative integer. Matches at least n times. For example, &#8216;o{2,}&#8217; does not match the &#8220;o&#8221; in &#8220;Bob&#8221; and matches all the o&#8217;s in &#8220;foooood&#8221;. &#8216;o{1,}&#8217; is equivalent to &#8216;o+&#8217;. &#8216;o{0,}&#8217; is equivalent to &#8216;o*&#8217;.<\/td><\/tr><tr><td>{n,m}<\/td><td>m and n are nonnegative integers, where n &lt;= m. Matches at least n and at most m times. For example, &#8220;o{1,3}&#8221; matches the first three o&#8217;s in &#8220;fooooood&#8221;. &#8216;o{0,1}&#8217; is equivalent to &#8216;o?&#8217;. Note that you cannot put a space between the comma and the numbers.<\/td><\/tr><tr><td>?<\/td><td>When this character immediately follows any of the other quantifiers (*, +, ?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. A non-greedy pattern matches as little of the searched string as possible, whereas the default greedy pattern matches as much of the searched string as possible. For example, in the string &#8220;oooo&#8221;, &#8216;o+?&#8217; matches a single &#8220;o&#8221;, while &#8216;o+&#8217; matches all &#8216;o&#8217;s.<\/td><\/tr><tr><td>.<\/td><td>(period) Matches any single character.<\/td><\/tr><tr><td>(pattern)<\/td><td>Matches pattern and captures the match. The captured match can be retrieved from the results by using the &#8220;wildcards&#8221; argument in triggers or aliases, or by using {3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}1 through to {3f0b0cf5c640d99e599990c4a720721a04ec3a009b1323dd81fc335ceb655a63}9 in the replacement text. To match parentheses characters ( ), use &#8216;\\(&#8216; or &#8216;\\)&#8217;.<\/td><\/tr><tr><td>(?:pattern)<\/td><td>Matches pattern but does not capture the match, that is, it is a non-capturing match that is not stored for possible later use. This is useful for combining parts of a pattern with the &#8220;or&#8221; character (|). For example, &#8216;industr(?:y|ies) is a more economical expression than &#8216;industry|industries&#8217;. It is also useful in situations where you need to match something, but are running out of wildcards.<\/td><\/tr><tr><td>(?=pattern)<\/td><td>Positive lookahead matches the search string at any point where a string matching pattern begins. This is a non-capturing match, that is, the match is not captured for possible later use. For example &#8216;foo(?=bar|bah)&#8217; matches the &#8220;foo&#8221; in &#8220;foobar&#8221; or &#8220;foobah&#8221; but not in &#8220;food&#8221;. Lookaheads do not consume characters, that is, after a match occurs, the search for the next match begins immediately following the last match, not after the characters that comprised the lookahead.<\/td><\/tr><tr><td>(?!pattern)<\/td><td>Negative lookahead matches the search string at any point where a string not matching pattern begins. This is a non-capturing match, that is, the match is not captured for possible later use. For example, &#8216;foo(?!bar)&#8217; matches any occurrence of &#8220;foo&#8221; that is not followed by &#8220;bar&#8221;. Note that the apparently similar pattern (?!foo)bar does not find an occurrence of &#8220;bar&#8221; that is preceded by something other than &#8220;foo&#8221;; it finds any occurrence of &#8220;bar&#8221; whatsoever, because the assertion (?!foo) is always true when the next three characters are &#8220;bar&#8221;. A lookbehind assertion is needed to achieve this effect. Lookaheads do not consume characters, that is, after a match occurs, the search for the next match begins immediately following the last match, not after the characters that comprised the lookahead.<\/td><\/tr><tr><td>(?&lt;=pattern)<\/td><td>Positive lookbehind matches the search string at any point where a string matching pattern begins.. For example, &#8216;(?&lt;=foo)bar&#8217; finds an occurrence of &#8220;bar&#8221; that is preceded by &#8220;foo&#8221;. The contents of a lookbehind assertion are restricted such that all the strings it matches must have a fixed length. however, if there are several alternatives, they do not all have to have the same fixed length. thus &#8216;(?&lt;=bullock|donkey)&#8217; is permitted, but &#8216;(?&lt;=dogs?|cats?)&#8217; causes an error at compile time.<\/td><\/tr><tr><td>(?&lt;!pattern)<\/td><td>Negative lookbehind matches the search string at any point where a string not matching pattern begins.. For example, &#8216;(?&lt;!foo)bar&#8217; finds an occurrence of &#8220;bar&#8221; that is not preceded by &#8220;foo&#8221;. The contents of a lookbehind assertion are restricted such that all the strings it matches must have a fixed length. however, if there are several alternatives, they do not all have to have the same fixed length. thus &#8216;(?&lt;!bullock|donkey)&#8217; is permitted, but &#8216;(?&lt;!dogs?|cats?)&#8217; causes an error at compile time.<\/td><\/tr><tr><td>x|y<\/td><td>Matches either x or y. For example, &#8216;z|food&#8217; matches &#8220;z&#8221; or &#8220;food&#8221;. &#8216;(z|f)ood&#8217; matches &#8220;zood&#8221; or &#8220;food&#8221;.<br>&#8216;(fish|chips|sauce)&#8217; matches &#8216;fish&#8217;, &#8216;chips&#8217;, or &#8216;sauce&#8217;.<\/td><\/tr><tr><td>[xyz]<\/td><td>A character set. Matches any one of the enclosed characters. For example, &#8216;[abc]&#8217; matches the &#8216;a&#8217; in &#8220;plain&#8221;.<\/td><\/tr><tr><td>[^xyz]<\/td><td>A negative character set. Matches any character not enclosed. For example, &#8216;[^abc]&#8217; matches the &#8216;p&#8217; in &#8220;plain&#8221;.<\/td><\/tr><tr><td>[a-z]<\/td><td>A range of characters. Matches any character in the specified range. For example, &#8216;[a-z]&#8217; matches any lowercase alphabetic character in the range &#8216;a&#8217; through &#8216;z&#8217;.<\/td><\/tr><tr><td>[^a-z]<\/td><td>A negative range characters. Matches any character not in the specified range. For example, &#8216;[^a-z]&#8217; matches any character not in the range &#8216;a&#8217; through &#8216;z&#8217;.<\/td><\/tr><tr><td>\\b<\/td><td>Matches a word boundary, that is, the position between a word and a space. For example, &#8216;er\\b&#8217; matches the &#8216;er&#8217; in &#8220;never&#8221; but not the &#8216;er&#8217; in &#8220;verb&#8221;.<\/td><\/tr><tr><td>\\B<\/td><td>Matches a nonword boundary. &#8216;er\\B&#8217; matches the &#8216;er&#8217; in &#8220;verb&#8221; but not the &#8216;er&#8217; in &#8220;never&#8221;.<\/td><\/tr><tr><td>\\cx<\/td><td>Matches the control character indicated by x. For example, \\cM matches a Control-M or carriage return character. The value of x must be in the range of A-Z or a-z. If not, c is assumed to be a literal &#8216;c&#8217; character. The precise effect of &#8220;\\cx&#8221; is as follows: if &#8220;x&#8221; is a lower case letter, it is converted to upper case. Then bit 6 of the character (hex 40) is inverted. Thus &#8220;\\cz&#8221; becomes hex 1A, but &#8220;\\c{&#8221; becomes hex 3B, while &#8220;\\c;&#8221; becomes hex 7B.<\/td><\/tr><tr><td>\\d<\/td><td>Matches a digit character. Equivalent to [0-9].<\/td><\/tr><tr><td>\\D<\/td><td>Matches a nondigit character. Equivalent to [^0-9].<\/td><\/tr><tr><td>\\f<\/td><td>Matches a form-feed character. Equivalent to \\x0c and \\cL.<\/td><\/tr><tr><td>\\n<\/td><td>Matches a newline character. Equivalent to \\x0a and \\cJ. Note that in MUSHclient newline characters will not occur in triggers or aliases as they have already been extracted prior to trigger\/alias matching.<\/td><\/tr><tr><td>\\r<\/td><td>Matches a carriage return character. Equivalent to \\x0d and \\cM.<\/td><\/tr><tr><td>\\s<\/td><td>Matches any whitespace character including space, tab, form-feed, etc. Equivalent to [\ufffd\\f\\n\\r\\t\\v].<\/td><\/tr><tr><td>\\S<\/td><td>Matches any non-white space character. Equivalent to [^\ufffd\\f\\n\\r\\t\\v].<\/td><\/tr><tr><td>\\t<\/td><td>Matches a tab character. Equivalent to \\x09 and \\cI.<\/td><\/tr><tr><td>\\v<\/td><td>Matches a vertical tab character. Equivalent to \\x0b and \\cK.<\/td><\/tr><tr><td>\\w<\/td><td>Matches any word character including underscore. Equivalent to &#8216;[A-Za-z0-9_]&#8217;.<\/td><\/tr><tr><td>\\W<\/td><td>Matches any nonword character. Equivalent to &#8216;[^A-Za-z0-9_]&#8217;.<\/td><\/tr><tr><td>\\xn<\/td><td>Matches n, where n is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For example, &#8216;\\x41&#8217; matches &#8220;A&#8221;. &#8216;\\x041&#8217; is equivalent to &#8216;\\x04&#8217; &amp; &#8220;1&#8221;. Allows ASCII codes to be used in regular expressions.<\/td><\/tr><tr><td>\\num<\/td><td>Matches num, where num is a positive integer. A reference back to captured matches. For example, &#8216;(.)\\1&#8217; matches two consecutive identical characters.<\/td><\/tr><tr><td>\\n<\/td><td>Identifies either an octal escape value or a backreference. If \\n is preceded by at least n captured subexpressions, n is a backreference. Otherwise, n is an octal escape value if n is an octal digit (0-7).<\/td><\/tr><tr><td>\\nm<\/td><td>Identifies either an octal escape value or a backreference. If \\nm is preceded by at least nm captured subexpressions, nm is a backreference. If \\nm is preceded by at least n captures, n is a backreference followed by literal m. If neither of the preceding conditions exists, \\nm matches octal escape value nm when n and m are octal digits (0-7).<\/td><\/tr><tr><td>\\nml<\/td><td>Matches octal escape value nml when n is an octal digit (0-3) and m and l are octal digits (0-7).<\/td><\/tr><tr><td>[[:alnum:]]<\/td><td>A character set matching letters and digits. Use [[:^alnum:]] to match anything other than letters and digits.<\/td><\/tr><tr><td>[[:alpha:]]<\/td><td>A character set matching letters. Use [[:^alpha:]] to match anything other than letters.<\/td><\/tr><tr><td>[[:ascii:]]<\/td><td>A character set matching character codes 0 &#8211; 127. Use [[:^ascii:]] to match anything other than character codes 0 &#8211; 127.<\/td><\/tr><tr><td>[[:cntrl:]]<\/td><td>A character set matching control characterss. Use [[:^cntrl:]] to match anything other than control characters.<\/td><\/tr><tr><td>[[:digit:]]<\/td><td>A character set matching digits (same as \\d). Use [[:^digit:]] to match anything other than digits.<\/td><\/tr><tr><td>[[:graph:]]<\/td><td>A character set matching printing characters, excluding space. Use [[:^graph:]] to match anything other than these.<\/td><\/tr><tr><td>[[:lower:]]<\/td><td>A character set matching lower case letters. Use [[:^lower:]] to match anything other than lower case letters.<\/td><\/tr><tr><td>[[:print:]]<\/td><td>A character set matching printing characters, including space. Use [[:^print:]] to match anything other than these.<\/td><\/tr><tr><td>[[:punct:]]<\/td><td>A character set matching printing characters, excluding letters and digits. Use [[:^punct:]] to match anything other than these.<\/td><\/tr><tr><td>[[:space:]]<\/td><td>A character set matching white space (same as \\s). Use [[:^space:]] to match anything other than white space.<\/td><\/tr><tr><td>[[:upper:]]<\/td><td>A character set matching upper case letters. Use [[:^upper:]] to match anything other than upper case letters.<\/td><\/tr><tr><td>[[:word:]]<\/td><td>A character set matching &#8220;word&#8221; characters (same as \\w). Use [[:^ word:]] to match anything other than &#8220;word&#8221; characters.<\/td><\/tr><tr><td>[[:xdigit:]]<\/td><td>A character set matching hexadecimal digits. Use [[:^xdigit:]] to match anything other than hexadecimal digits.<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Table of metacharacters Character Description \\ Marks the next character as either a special character, a literal, a backreference, or an octal escape. For example, &#8216;n&#8217; matches the character &#8220;n&#8221;. &#8216;\\n&#8217; matches a newline character. The sequence &#8216;\\\\&#8217; matches &#8220;\\&#8221; &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=870\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-870","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=870"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/870\/revisions"}],"predecessor-version":[{"id":871,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/870\/revisions\/871"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}