{"id":303,"date":"2007-10-08T00:00:00","date_gmt":"2007-10-08T00:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=303"},"modified":"2007-10-08T00:00:00","modified_gmt":"2007-10-08T00:00:00","slug":"Summary of regular-expression constructs ","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=303","title":{"rendered":"Summary of regular-expression constructs"},"content":{"rendered":"<p><DIV><br \/>\n<H4>Summary of regular-expression constructs <\/H4><br \/>\n<TABLE cellSpacing=0 cellPadding=1 summary=\"Regular expression constructs, and what they match\" border=0><br \/>\n<TBODY><br \/>\n<TR align=left><br \/>\n<TH id=construct align=left bgColor=#ccccff>Construct<\/TH><br \/>\n<TH id=matches align=left bgColor=#ccccff>Matches<\/TH><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=characters colSpan=2>Characters<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><I>x<\/I><\/TD><br \/>\n<TD headers=matches>The character <I>x<\/I><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\\\<\/TT><\/TD><br \/>\n<TD headers=matches>The backslash character<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\0<\/TT><I>n<\/I><\/TD><br \/>\n<TD headers=matches>The character with octal value <TT>0<\/TT><I>n<\/I> (0&nbsp;<TT>&lt;=<\/TT>&nbsp;<I>n<\/I>&nbsp;<TT>&lt;=<\/TT>&nbsp;7)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\0<\/TT><I>nn<\/I><\/TD><br \/>\n<TD headers=matches>The character with octal value <TT>0<\/TT><I>nn<\/I> (0&nbsp;<TT>&lt;=<\/TT>&nbsp;<I>n<\/I>&nbsp;<TT>&lt;=<\/TT>&nbsp;7)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\0<\/TT><I>mnn<\/I><\/TD><br \/>\n<TD headers=matches>The character with octal value <TT>0<\/TT><I>mnn<\/I> (0&nbsp;<TT>&lt;=<\/TT>&nbsp;<I>m<\/I>&nbsp;<TT>&lt;=<\/TT>&nbsp;3, 0&nbsp;<TT>&lt;=<\/TT>&nbsp;<I>n<\/I>&nbsp;<TT>&lt;=<\/TT>&nbsp;7)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\x<\/TT><I>hh<\/I><\/TD><br \/>\n<TD headers=matches>The character with hexadecimal&nbsp;value&nbsp;<TT>0x<\/TT><I>hh<\/I><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\u<\/TT><I>hhhh<\/I><\/TD><br \/>\n<TD headers=matches>The character with hexadecimal&nbsp;value&nbsp;<TT>0x<\/TT><I>hhhh<\/I><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=matches><TT>\\t<\/TT><\/TD><br \/>\n<TD headers=matches>The tab character (<TT>&#8216;\\u0009&#8217;<\/TT>)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\n<\/TT><\/TD><br \/>\n<TD headers=matches>The newline (line feed) character (<TT>&#8216;\\u000A&#8217;<\/TT>)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\r<\/TT><\/TD><br \/>\n<TD headers=matches>The carriage-return character (<TT>&#8216;\\u000D&#8217;<\/TT>)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\f<\/TT><\/TD><br \/>\n<TD headers=matches>The form-feed character (<TT>&#8216;\\u000C&#8217;<\/TT>)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\a<\/TT><\/TD><br \/>\n<TD headers=matches>The alert (bell) character (<TT>&#8216;\\u0007&#8217;<\/TT>)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\e<\/TT><\/TD><br \/>\n<TD headers=matches>The escape character (<TT>&#8216;\\u001B&#8217;<\/TT>)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct characters\"><TT>\\c<\/TT><I>x<\/I><\/TD><br \/>\n<TD headers=matches>The control character corresponding to <I>x<\/I><\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=classes colSpan=2>Character classes<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct classes\"><TT>[abc]<\/TT><\/TD><br \/>\n<TD headers=matches><TT>a<\/TT>, <TT>b<\/TT>, or <TT>c<\/TT> (simple class)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct classes\"><TT>[^abc]<\/TT><\/TD><br \/>\n<TD headers=matches>Any character except <TT>a<\/TT>, <TT>b<\/TT>, or <TT>c<\/TT> (negation)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct classes\"><TT>[a-zA-Z]<\/TT><\/TD><br \/>\n<TD headers=matches><TT>a<\/TT> through <TT>z<\/TT> or <TT>A<\/TT> through <TT>Z<\/TT>, inclusive (range)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct classes\"><TT>[a-d[m-p]]<\/TT><\/TD><br \/>\n<TD headers=matches><TT>a<\/TT> through <TT>d<\/TT>, or <TT>m<\/TT> through <TT>p<\/TT>: <TT>[a-dm-p]<\/TT> (union)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct classes\"><TT>[a-z&amp;&amp;[def]]<\/TT><\/TD><br \/>\n<TD headers=matches><TT>d<\/TT>, <TT>e<\/TT>, or <TT>f<\/TT> (intersection)<\/TD><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct classes\"><TT>[a-z&amp;&amp;[^bc]]<\/TT><\/TD><br \/>\n<TD headers=matches><TT>a<\/TT> through <TT>z<\/TT>, except for <TT>b<\/TT> and <TT>c<\/TT>: <TT>[ad-z]<\/TT> (subtraction)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct classes\"><TT>[a-z&amp;&amp;[^m-p]]<\/TT><\/TD><br \/>\n<TD headers=matches><TT>a<\/TT> through <TT>z<\/TT>, and not <TT>m<\/TT> through <TT>p<\/TT>: <TT>[a-lq-z]<\/TT>(subtraction)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=predef colSpan=2>Predefined character classes<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct predef\"><TT>.<\/TT><\/TD><br \/>\n<TD headers=matches>Any character (may or may not match <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#lt\" s_oidt=\"0\" s_oid=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#lt\">line terminators<\/A>)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct predef\"><TT>\\d<\/TT><\/TD><br \/>\n<TD headers=matches>A digit: <TT>[0-9]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct predef\"><TT>\\D<\/TT><\/TD><br \/>\n<TD headers=matches>A non-digit: <TT>[^0-9]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct predef\"><TT>\\s<\/TT><\/TD><br \/>\n<TD headers=matches>A whitespace character: <TT>[ \\t\\n\\x0B\\f\\r]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct predef\"><TT>\\S<\/TT><\/TD><br \/>\n<TD headers=matches>A non-whitespace character: <TT>[^\\s]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct predef\"><TT>\\w<\/TT><\/TD><br \/>\n<TD headers=matches>A word character: <TT>[a-zA-Z_0-9]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct predef\"><TT>\\W<\/TT><\/TD><br \/>\n<TD headers=matches>A non-word character: <TT>[^\\w]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=posix colSpan=2>POSIX character classes<\/B> (US-ASCII only)<B><\/B><\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{Lower}<\/TT><\/TD><br \/>\n<TD headers=matches>A lower-case alphabetic character: <TT>[a-z]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{Upper}<\/TT><\/TD><br \/>\n<TD headers=matches>An upper-case alphabetic character:<TT>[A-Z]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{ASCII}<\/TT><\/TD><br \/>\n<TD headers=matches>All ASCII:<TT>[\\x00-\\x7F]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{Alpha}<\/TT><\/TD><br \/>\n<TD headers=matches>An alphabetic character:<TT>[\\p{Lower}\\p{Upper}]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{Digit}<\/TT><\/TD><br \/>\n<TD headers=matches>A decimal digit: <TT>[0-9]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{Alnum}<\/TT><\/TD><br \/>\n<TD headers=matches>An alphanumeric character:<TT>[\\p{Alpha}\\p{Digit}]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{Punct}<\/TT><\/TD><br \/>\n<TD headers=matches>Punctuation: One of <TT>!&#8221;#$%&amp;'()*+,-.\/:;&lt;=&gt;?@[\\]^_`{|}~<\/TT><\/TD><\/TR><!-- <tt>[\\!\"#\\$%&'\\(\\)\\*\\+,\\-\\.\/:;\\<=\\>\\?@\\[\\\\\\]\\^_`\\{\\|\\}~]<\/tt>\n          <tt>[\\X21-\\X2F\\X31-\\X40\\X5B-\\X60\\X7B-\\X7E]<\/tt> --><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{Graph}<\/TT><\/TD><br \/>\n<TD headers=matches>A visible character: <TT>[\\p{Alnum}\\p{Punct}]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{Print}<\/TT><\/TD><br \/>\n<TD headers=matches>A printable character: <TT>[\\p{Graph}]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{Blank}<\/TT><\/TD><br \/>\n<TD headers=matches>A space or a tab: <TT>[ \\t]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{Cntrl}<\/TT><\/TD><br \/>\n<TD headers=matches>A control character: <TT>[\\x00-\\x1F\\x7F]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{XDigit}<\/TT><\/TD><br \/>\n<TD headers=matches>A hexadecimal digit: <TT>[0-9a-fA-F]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct posix\"><TT>\\p{Space}<\/TT><\/TD><br \/>\n<TD headers=matches>A whitespace character: <TT>[ \\t\\n\\x0B\\f\\r]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=unicode colSpan=2>Classes for Unicode blocks and categories<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct unicode\"><TT>\\p{InGreek}<\/TT><\/TD><br \/>\n<TD headers=matches>A character in the Greek&nbsp;block (simple <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#ubc\">block<\/A>)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct unicode\"><TT>\\p{Lu}<\/TT><\/TD><br \/>\n<TD headers=matches>An uppercase letter (simple <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#ubc\">category<\/A>)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct unicode\"><TT>\\p{Sc}<\/TT><\/TD><br \/>\n<TD headers=matches>A currency symbol<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct unicode\"><TT>\\P{InGreek}<\/TT><\/TD><br \/>\n<TD headers=matches>Any character except one in the Greek block (negation)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct unicode\"><TT>[\\p{L}&amp;&amp;[^\\p{Lu}]]&nbsp;<\/TT><\/TD><br \/>\n<TD headers=matches>Any letter except an uppercase letter (subtraction)<\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=bounds colSpan=2>Boundary matchers<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct bounds\"><TT>^<\/TT><\/TD><br \/>\n<TD headers=matches>The beginning of a line<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct bounds\"><TT>$<\/TT><\/TD><br \/>\n<TD headers=matches>The end of a line<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct bounds\"><TT>\\b<\/TT><\/TD><br \/>\n<TD headers=matches>A word boundary<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct bounds\"><TT>\\B<\/TT><\/TD><br \/>\n<TD headers=matches>A non-word boundary<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct bounds\"><TT>\\A<\/TT><\/TD><br \/>\n<TD headers=matches>The beginning of the input<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct bounds\"><TT>\\G<\/TT><\/TD><br \/>\n<TD headers=matches>The end of the previous match<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct bounds\"><TT>\\Z<\/TT><\/TD><br \/>\n<TD headers=matches>The end of the input but for the final <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#lt\">terminator<\/A>, if&nbsp;any<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct bounds\"><TT>\\z<\/TT><\/TD><br \/>\n<TD headers=matches>The end of the input<\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=greedy colSpan=2>Greedy quantifiers<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct greedy\"><I>X<\/I><TT>?<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, once or not at all<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct greedy\"><I>X<\/I><TT>*<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, zero or more times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct greedy\"><I>X<\/I><TT>+<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, one or more times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct greedy\"><I>X<\/I><TT>{<\/TT><I>n<\/I><TT>}<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, exactly <I>n<\/I> times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct greedy\"><I>X<\/I><TT>{<\/TT><I>n<\/I><TT>,}<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, at least <I>n<\/I> times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct greedy\"><I>X<\/I><TT>{<\/TT><I>n<\/I><TT>,<\/TT><I>m<\/I><TT>}<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, at least <I>n<\/I> but not more than <I>m<\/I> times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=reluc colSpan=2>Reluctant quantifiers<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct reluc\"><I>X<\/I><TT>??<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, once or not at all<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct reluc\"><I>X<\/I><TT>*?<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, zero or more times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct reluc\"><I>X<\/I><TT>+?<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, one or more times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct reluc\"><I>X<\/I><TT>{<\/TT><I>n<\/I><TT>}?<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, exactly <I>n<\/I> times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct reluc\"><I>X<\/I><TT>{<\/TT><I>n<\/I><TT>,}?<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, at least <I>n<\/I> times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct reluc\"><I>X<\/I><TT>{<\/TT><I>n<\/I><TT>,<\/TT><I>m<\/I><TT>}?<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, at least <I>n<\/I> but not more than <I>m<\/I> times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=poss colSpan=2>Possessive quantifiers<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct poss\"><I>X<\/I><TT>?+<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, once or not at all<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct poss\"><I>X<\/I><TT>*+<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, zero or more times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct poss\"><I>X<\/I><TT>++<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, one or more times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct poss\"><I>X<\/I><TT>{<\/TT><I>n<\/I><TT>}+<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, exactly <I>n<\/I> times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct poss\"><I>X<\/I><TT>{<\/TT><I>n<\/I><TT>,}+<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, at least <I>n<\/I> times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct poss\"><I>X<\/I><TT>{<\/TT><I>n<\/I><TT>,<\/TT><I>m<\/I><TT>}+<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, at least <I>n<\/I> but not more than <I>m<\/I> times<\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=logical colSpan=2>Logical operators<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct logical\"><I>XY<\/I><\/TD><br \/>\n<TD headers=matches><I>X<\/I> followed by <I>Y<\/I><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct logical\"><I>X<\/I><TT>|<\/TT><I>Y<\/I><\/TD><br \/>\n<TD headers=matches>Either <I>X<\/I> or <I>Y<\/I><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct logical\"><TT>(<\/TT><I>X<\/I><TT>)<\/TT><\/TD><br \/>\n<TD headers=matches>X, as a <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#cg\">capturing group<\/A><\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=backref colSpan=2>Back references<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=bottom headers=\"construct backref\"><TT>\\<\/TT><I>n<\/I><\/TD><br \/>\n<TD vAlign=bottom headers=matches>Whatever the <I>n<\/I><SUP>th<\/SUP> <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#cg\">capturing group<\/A> matched<\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=quot colSpan=2>Quotation<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct quot\"><TT>\\<\/TT><\/TD><br \/>\n<TD headers=matches>Nothing, but quotes the following character<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct quot\"><TT>\\Q<\/TT><\/TD><br \/>\n<TD headers=matches>Nothing, but quotes all characters until <TT>\\E<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct quot\"><TT>\\E<\/TT><\/TD><br \/>\n<TD headers=matches>Nothing, but ends quoting started by <TT>\\Q<\/TT><\/TD><\/TR><!-- Metachars: !$()*+.<>?[\\]^{|} --><br \/>\n<TR><br \/>\n<TH>&nbsp;<\/TH><\/TR><br \/>\n<TR align=left><br \/>\n<TH id=special colSpan=2>Special constructs (non-capturing)<\/TH><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct special\"><TT>(?:<\/TT><I>X<\/I><TT>)<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, as a non-capturing group<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct special\"><TT>(?idmsux-idmsux)&nbsp;<\/TT><\/TD><br \/>\n<TD headers=matches>Nothing, but turns match flags on &#8211; off<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct special\"><TT>(?idmsux-idmsux:<\/TT><I>X<\/I><TT>)<\/TT>&nbsp;&nbsp;<\/TD><br \/>\n<TD headers=matches><I>X<\/I>, as a <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#cg\">non-capturing group<\/A> with the given flags on &#8211; off<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct special\"><TT>(?=<\/TT><I>X<\/I><TT>)<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, via zero-width positive lookahead<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct special\"><TT>(?!<\/TT><I>X<\/I><TT>)<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, via zero-width negative lookahead<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct special\"><TT>(?&lt;=<\/TT><I>X<\/I><TT>)<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, via zero-width positive lookbehind<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct special\"><TT>(?&lt;!<\/TT><I>X<\/I><TT>)<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, via zero-width negative lookbehind<\/TD><\/TR><br \/>\n<TR><br \/>\n<TD vAlign=top headers=\"construct special\"><TT>(?&gt;<\/TT><I>X<\/I><TT>)<\/TT><\/TD><br \/>\n<TD headers=matches><I>X<\/I>, as an independent, non-capturing group<\/TD><\/TR><\/TBODY><\/TABLE><br \/>\n<HR><br \/>\n<A name=bs><br \/>\n<H4>Backslashes, escapes, and quoting <\/H4><br \/>\n<P>The backslash character (<TT>&#8216;\\&#8217;<\/TT>) serves to introduce escaped constructs, as defined in the table above, as well as to quote characters that otherwise would be interpreted as unescaped constructs. Thus the expression <TT>\\\\<\/TT> matches a single backslash and <TT>\\{<\/TT> matches a left brace.<br \/>\n<P>It is an error to use a backslash prior to any alphabetic character that does not denote an escaped construct; these are reserved for future extensions to the regular-expression language. A backslash may be used prior to a non-alphabetic character regardless of whether that character is part of an unescaped construct.<br \/>\n<P>Backslashes within string literals in Java source code are interpreted as required by the <A href=\"http:\/\/java.sun.com\/docs\/books\/jls\/second_edition\/html\/j.title.doc.html\">Java Language Specification<\/A> as either <A href=\"http:\/\/java.sun.com\/docs\/books\/jls\/second_edition\/html\/lexical.doc.html#100850\">Unicode escapes<\/A> or other <A href=\"http:\/\/java.sun.com\/docs\/books\/jls\/second_edition\/html\/lexical.doc.html#101089\">character escapes<\/A>. It is therefore necessary to double backslashes in string literals that represent regular expressions to protect them from interpretation by the Java bytecode compiler. The string literal <TT>&#8220;\\b&#8221;<\/TT>, for example, matches a single backspace character when interpreted as a regular expression, while <TT>&#8220;\\\\b&#8221;<\/TT> matches a word boundary. The string literal <TT>&#8220;\\(hello\\)&#8221;<\/TT> is illegal and leads to a compile-time error; in order to match the string <TT>(hello)<\/TT> the string literal <TT>&#8220;\\\\(hello\\\\)&#8221;<\/TT> must be used. <A name=cc><br \/>\n<H4>Character Classes <\/H4><br \/>\n<P>Character classes may appear within other character classes, and may be composed by the union operator (implicit) and the intersection operator (<TT>&amp;&amp;<\/TT>). The union operator denotes a class that contains every character that is in at least one of its operand classes. The intersection operator denotes a class that contains every character that is in both of its operand classes.<br \/>\n<P>The precedence of character-class operators is as follows, from highest to lowest:<br \/>\n<BLOCKQUOTE><br \/>\n<TABLE cellSpacing=0 cellPadding=1 summary=\"Precedence of character class operators.\" border=0><br \/>\n<TBODY><br \/>\n<TR><br \/>\n<TH>1&nbsp;&nbsp;&nbsp;&nbsp;<\/TH><br \/>\n<TD>Literal escape&nbsp;&nbsp;&nbsp;&nbsp;<\/TD><br \/>\n<TD><TT>\\x<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>2&nbsp;&nbsp;&nbsp;&nbsp;<\/TH><br \/>\n<TD>Grouping<\/TD><br \/>\n<TD><TT>[&#8230;]<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>3&nbsp;&nbsp;&nbsp;&nbsp;<\/TH><br \/>\n<TD>Range<\/TD><br \/>\n<TD><TT>a-z<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>4&nbsp;&nbsp;&nbsp;&nbsp;<\/TH><br \/>\n<TD>Union<\/TD><br \/>\n<TD><TT>[a-e][i-u]<TT><\/TT><\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>5&nbsp;&nbsp;&nbsp;&nbsp;<\/TH><br \/>\n<TD>Intersection<\/TD><br \/>\n<TD><TT>[a-z&amp;&amp;[aeiou]]<\/TT><\/TD><\/TR><\/TBODY><\/TABLE><\/BLOCKQUOTE><br \/>\n<P>Note that a different set of metacharacters are in effect inside a character class than outside a character class. For instance, the regular expression <TT>.<\/TT> loses its special meaning inside a character class, while the expression <TT>&#8211;<\/TT> becomes a range forming metacharacter. <A name=lt><br \/>\n<H4>Line terminators <\/H4><br \/>\n<P>A <I>line terminator<\/I> is a one- or two-character sequence that marks the end of a line of the input character sequence. The following are recognized as line terminators:<br \/>\n<UL><br \/>\n<LI>A newline (line feed) character&nbsp;(<TT>&#8216;\\n&#8217;<\/TT>),<br \/>\n<LI>A carriage-return character followed immediately by a newline character&nbsp;(<TT>&#8220;\\r\\n&#8221;<\/TT>),<br \/>\n<LI>A standalone carriage-return character&nbsp;(<TT>&#8216;\\r&#8217;<\/TT>),<br \/>\n<LI>A next-line character&nbsp;(<TT>&#8216;\\u0085&#8217;<\/TT>),<br \/>\n<LI>A line-separator character&nbsp;(<TT>&#8216;\\u2028&#8217;<\/TT>), or<br \/>\n<LI>A paragraph-separator character&nbsp;(<TT>&#8216;\\u2029<\/TT>). <\/LI><\/UL><br \/>\n<P>If <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#UNIX_LINES\" s_oidt=\"0\" s_oid=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#UNIX_LINES\"><CODE>UNIX_LINES<\/CODE><\/A> mode is activated, then the only line terminators recognized are newline characters.<br \/>\n<P>The regular expression <TT>.<\/TT> matches any character except a line terminator unless the <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#DOTALL\"><CODE>DOTALL<\/CODE><\/A> flag is specified.<br \/>\n<P>By default, the regular expressions <TT>^<\/TT> and <TT>$<\/TT> ignore line terminators and only match at the beginning and the end, respectively, of the entire input sequence. If <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#MULTILINE\"><CODE>MULTILINE<\/CODE><\/A> mode is activated then <TT>^<\/TT> matches at the beginning of input and after any line terminator except at the end of input. When in <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#MULTILINE\"><CODE>MULTILINE<\/CODE><\/A> mode <TT>$<\/TT> matches just before a line terminator or the end of the input sequence. <A name=cg><br \/>\n<H4>Groups and capturing <\/H4><br \/>\n<P>Capturing groups are numbered by counting their opening parentheses from left to right. In the expression <TT>((A)(B(C)))<\/TT>, for example, there are four such groups: <\/P><br \/>\n<BLOCKQUOTE><br \/>\n<TABLE cellSpacing=0 cellPadding=1 summary=\"Capturing group numberings\"><br \/>\n<TBODY><br \/>\n<TR><br \/>\n<TH>1&nbsp;&nbsp;&nbsp;&nbsp;<\/TH><br \/>\n<TD><TT>((A)(B(C)))<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>2&nbsp;&nbsp;&nbsp;&nbsp;<\/TH><br \/>\n<TD><TT>(A)<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>3&nbsp;&nbsp;&nbsp;&nbsp;<\/TH><br \/>\n<TD><TT>(B(C))<\/TT><\/TD><\/TR><br \/>\n<TR><br \/>\n<TH>4&nbsp;&nbsp;&nbsp;&nbsp;<\/TH><br \/>\n<TD><TT>(C)<\/TT><\/TD><\/TR><\/TBODY><\/TABLE><\/BLOCKQUOTE><br \/>\n<P>Group zero always stands for the entire expression.<br \/>\n<P>Capturing groups are so named because, during a match, each subsequence of the input sequence that matches such a group is saved. The captured subsequence may be used later in the expression, via a back reference, and may also be retrieved from the matcher once the match operation is complete.<br \/>\n<P>The captured input associated with a group is always the subsequence that the group most recently matched. If a group is evaluated a second time because of quantification then its previously-captured value, if any, will be retained if the second evaluation fails. Matching the string <TT>&#8220;aba&#8221;<\/TT> against the expression <TT>(a(b)?)+<\/TT>, for example, leaves group two set to <TT>&#8220;b&#8221;<\/TT>. All captured input is discarded at the beginning of each match.<br \/>\n<P>Groups beginning with <TT>(?<\/TT> are pure, <I>non-capturing<\/I> groups that do not capture text and do not count towards the group total.<br \/>\n<H4>Unicode support <\/H4><br \/>\n<P>This class follows <A href=\"http:\/\/www.unicode.org\/unicode\/reports\/tr18\/\"><I>Unicode Technical Report #18: Unicode Regular Expression Guidelines<\/I><\/A>, implementing its second level of support though with a slightly different concrete syntax.<br \/>\n<P>Unicode escape sequences such as <TT>\\u2014<\/TT> in Java source code are processed as described in <A href=\"http:\/\/java.sun.com\/docs\/books\/jls\/second_edition\/html\/lexical.doc.html#100850\">?3.3<\/A> of the Java Language Specification. Such escape sequences are also implemented directly by the regular-expression parser so that Unicode escapes can be used in expressions that are read from files or from the keyboard. Thus the strings <TT>&#8220;\\u2014&#8221;<\/TT> and <TT>&#8220;\\\\u2014&#8221;<\/TT>, while not equal, compile into the same pattern, which matches the character with hexadecimal value <TT>0x2014<\/TT>. <A name=ubc><br \/>\n<P>Unicode blocks and categories are written with the <TT>\\p<\/TT> and <TT>\\P<\/TT> constructs as in Perl. <TT>\\p{<\/TT><I>prop<\/I><TT>}<\/TT> matches if the input has the property <I>prop<\/I>, while \\P{<\/TT><I>prop<\/I><TT>}<\/TT> does not match if the input has that property. Blocks are specified with the prefix <TT>In<\/TT>, as in <TT>InMongolian<\/TT>. Categories may be specified with the optional prefix <TT>Is<\/TT>: Both <TT>\\p{L}<\/TT> and <TT>\\p{IsL}<\/TT> denote the category of Unicode letters. Blocks and categories can be used both inside and outside of a character class.<br \/>\n<P>The supported blocks and categories are those of <A href=\"http:\/\/www.unicode.org\/unicode\/standard\/standard.html\"><I>The Unicode Standard, Version&nbsp;3.0<\/I><\/A>. The block names are those defined in Chapter&nbsp;14 and in the file <A href=\"http:\/\/www.unicode.org\/Public\/3.0-Update\/Blocks-3.txt\">Blocks-3.txt <\/A>of the <A href=\"http:\/\/www.unicode.org\/Public\/3.0-Update\/UnicodeCharacterDatabase-3.0.0.html\">Unicode Character Database<\/A> except that the spaces are removed; <TT>&#8220;Basic Latin&#8221;<\/TT>, for example, becomes <TT>&#8220;BasicLatin&#8221;<\/TT>. The category names are those defined in table 4-5 of the Standard (p.&nbsp;88), both normative and informative.<br \/>\n<H4>Comparison to Perl 5 <\/H4><br \/>\n<P>Perl constructs not supported by this class: <\/P><br \/>\n<UL><br \/>\n<LI><br \/>\n<P>The conditional constructs <TT>(?{<\/TT><I>X<\/I><TT>})<\/TT> and <TT>(?(<\/TT><I>condition<\/I><TT>)<\/TT><I>X<\/I><TT>|<\/TT><I>Y<\/I><TT>)<\/TT>, <\/P><br \/>\n<LI><br \/>\n<P>The embedded code constructs <TT>(?{<\/TT><I>code<\/I><TT>})<\/TT> and <TT>(??{<\/TT><I>code<\/I><TT>})<\/TT>,<\/P><br \/>\n<LI><br \/>\n<P>The embedded comment syntax <TT>(?#comment)<\/TT>, and <\/P><br \/>\n<LI><br \/>\n<P>The preprocessing operations <TT>\\l<\/TT> <TT>\\u<\/TT>, <TT>\\L<\/TT>, and <TT>\\U<\/TT>. <\/P><\/LI><\/UL><br \/>\n<P>Constructs supported by this class but not by Perl: <\/P><br \/>\n<UL><br \/>\n<LI><br \/>\n<P>Possessive quantifiers, which greedily match as much as they can and do not back off, even when doing so would allow the overall match to succeed. <\/P><br \/>\n<LI><br \/>\n<P>Character-class union and intersection as described <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Pattern.html#cc\">above<\/A>.<\/P><\/LI><\/UL><br \/>\n<P>Notable differences from Perl: <\/P><br \/>\n<UL><br \/>\n<LI><br \/>\n<P>In Perl, <TT>\\1<\/TT> through <TT>\\9<\/TT> are always interpreted as back references; a backslash-escaped number greater than <TT>9<\/TT> is treated as a back reference if at least that many subexpressions exist, otherwise it is interpreted, if possible, as an octal escape. In this class octal escapes must always begin with a zero. In this class, <TT>\\1<\/TT> through <TT>\\9<\/TT> are always interpreted as back references, and a larger number is accepted as a back reference if at least that many subexpressions exist at that point in the regular expression, otherwise the parser will drop digits until the number is smaller or equal to the existing number of groups or it is one digit. <\/P><br \/>\n<LI><br \/>\n<P>Perl uses the <TT>g<\/TT> flag to request a match that resumes where the last match left off. This functionality is provided implicitly by the <A title=\"class in java.util.regex\" href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Matcher.html\"><CODE>Matcher<\/CODE><\/A> class: Repeated invocations of the <A href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/Matcher.html#find()\"><CODE>find<\/CODE><\/A> method will resume where the last match left off, unless the matcher is reset. <\/P><br \/>\n<LI><br \/>\n<P>In Perl, embedded flags at the top level of an expression affect the whole expression. In this class, embedded flags always take effect at the point at which they appear, whether they are at the top level or within a group; in the latter case, flags are restored at the end of the group just as in Perl. <\/P><br \/>\n<LI><br \/>\n<P>Perl is forgiving about malformed matching constructs, as in the expression <TT>*a<\/TT>, as well as dangling brackets, as in the expression <TT>abc]<\/TT>, and treats them as literals. This class also accepts dangling brackets but is strict about dangling metacharacters like +, ? and *, and will throw a <A title=\"class in java.util.regex\" href=\"http:\/\/java.sun.com\/j2se\/1.4.2\/docs\/api\/java\/util\/regex\/PatternSyntaxException.html\"><CODE>PatternSyntaxException<\/CODE><\/A> if it encounters them. <\/P><\/LI><\/UL><br \/>\n<P>For a more precise description of the behavior of regular expression constructs, please see <A href=\"http:\/\/www.oreilly.com\/catalog\/regex2\/\"><I>Mastering Regular Expressions, 2nd Edition<\/I>, Jeffrey E. F. Friedl, O&#8217;Reilly and Associates, 2002.<\/A> <\/P><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary of regular-expression constructs Construct Matches &nbsp; Characters x The character x \\\\ The backslash character \\0n The character with octal value 0n (0&nbsp;&lt;=&nbsp;n&nbsp;&lt;=&nbsp;7) \\0nn The character with octal value 0nn (0&nbsp;&lt;=&nbsp;n&nbsp;&lt;=&nbsp;7) \\0mnn The character with octal value 0mnn (0&nbsp;&lt;=&nbsp;m&nbsp;&lt;=&nbsp;3, 0&nbsp;&lt;=&nbsp;n&nbsp;&lt;=&nbsp;7) \\xhh The character with hexadecimal&nbsp;value&nbsp;0xhh \\uhhhh The character with hexadecimal&nbsp;value&nbsp;0xhhhh \\t The tab character &hellip; <a href=\"https:\/\/www.strongd.net\/?p=303\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Summary of regular-expression constructs<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-303","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=303"}],"version-history":[{"count":0,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/303\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}