CINXE.COM

Regex Tutorial - Unicode Characters and Properties

<!DOCTYPE html> <html lang="en"><head><meta charset="utf-8"><link rel=canonical href='https://https://www.regular-expressions.info//unicode.html'><title>Regex Tutorial - Unicode Characters and Properties</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="author" content="Jan Goyvaerts"> <meta name="description" content=""> <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 Tutorial</TD></TR><TR><TD><A HREF="tutorial.html" TARGET=_top>Introduction</A></TD></TR><TR><TD><A HREF="tutorialcnt.html" TARGET=_top>Table of Contents</A></TD></TR><TR><TD><A HREF="characters.html" TARGET=_top>Special Characters</A></TD></TR><TR><TD><A HREF="nonprint.html" TARGET=_top>Non-Printable Characters</A></TD></TR><TR><TD><A HREF="engine.html" TARGET=_top>Regex Engine Internals</A></TD></TR><TR><TD><A HREF="charclass.html" TARGET=_top>Character Classes</A></TD></TR><TR><TD><A HREF="charclasssubtract.html" TARGET=_top>Character Class Subtraction</A></TD></TR><TR><TD><A HREF="charclassintersect.html" TARGET=_top>Character Class Intersection</A></TD></TR><TR><TD><A HREF="shorthand.html" TARGET=_top>Shorthand Character Classes</A></TD></TR><TR><TD><A HREF="dot.html" TARGET=_top>Dot</A></TD></TR><TR><TD><A HREF="anchors.html" TARGET=_top>Anchors</A></TD></TR><TR><TD><A HREF="wordboundaries.html" TARGET=_top>Word Boundaries</A></TD></TR><TR><TD><A HREF="alternation.html" TARGET=_top>Alternation</A></TD></TR><TR><TD><A HREF="optional.html" TARGET=_top>Optional Items</A></TD></TR><TR><TD><A HREF="repeat.html" TARGET=_top>Repetition</A></TD></TR><TR><TD><A HREF="brackets.html" TARGET=_top>Grouping &amp; Capturing</A></TD></TR><TR><TD><A HREF="backref.html" TARGET=_top>Backreferences</A></TD></TR><TR><TD><A HREF="backref2.html" TARGET=_top>Backreferences, part 2</A></TD></TR><TR><TD><A HREF="named.html" TARGET=_top>Named Groups</A></TD></TR><TR><TD><A HREF="backrefrel.html" TARGET=_top>Relative Backreferences</A></TD></TR><TR><TD><A HREF="branchreset.html" TARGET=_top>Branch Reset Groups</A></TD></TR><TR><TD><A HREF="freespacing.html" TARGET=_top>Free-Spacing &amp; Comments</A></TD></TR><TR><TD><A HREF="unicode.html" TARGET=_top>Unicode</A></TD></TR><TR><TD><A HREF="modifiers.html" TARGET=_top>Mode Modifiers</A></TD></TR><TR><TD><A HREF="atomic.html" TARGET=_top>Atomic Grouping</A></TD></TR><TR><TD><A HREF="possessive.html" TARGET=_top>Possessive Quantifiers</A></TD></TR><TR><TD><A HREF="lookaround.html" TARGET=_top>Lookahead &amp; Lookbehind</A></TD></TR><TR><TD><A HREF="lookaround2.html" TARGET=_top>Lookaround, part 2</A></TD></TR><TR><TD><A HREF="keep.html" TARGET=_top>Keep Text out of The Match</A></TD></TR><TR><TD><A HREF="conditional.html" TARGET=_top>Conditionals</A></TD></TR><TR><TD><A HREF="balancing.html" TARGET=_top>Balancing Groups</A></TD></TR><TR><TD><A HREF="recurse.html" TARGET=_top>Recursion</A></TD></TR><TR><TD><A HREF="subroutine.html" TARGET=_top>Subroutines</A></TD></TR><TR><TD><A HREF="recurseinfinite.html" TARGET=_top>Infinite Recursion</A></TD></TR><TR><TD><A HREF="recurserepeat.html" TARGET=_top>Recursion &amp; Quantifiers</A></TD></TR><TR><TD><A HREF="recursecapture.html" TARGET=_top>Recursion &amp; Capturing</A></TD></TR><TR><TD><A HREF="recursebackref.html" TARGET=_top>Recursion &amp; Backreferences</A></TD></TR><TR><TD><A HREF="recursebacktrack.html" TARGET=_top>Recursion &amp; Backtracking</A></TD></TR><TR><TD><A HREF="posixbrackets.html" TARGET=_top>POSIX Bracket Expressions</A></TD></TR><TR><TD><A HREF="zerolength.html" TARGET=_top>Zero-Length Matches</A></TD></TR><TR><TD><A HREF="continue.html" TARGET=_top>Continuing Matches</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 style="height:130px"><A HREF="https://www.regexbuddy.com/create.html" TARGET="_top"><picture><source media="(max-width: 370px)" srcset="ads/320/rxbtutorial100.png 1x, ads/320/rxbtutorial150.png 1.5x, ads/320/rxbtutorial200.png 2x, ads/320/rxbtutorial250.png 2.5x, ads/320/rxbtutorial300.png 3x, ads/320/rxbtutorial350.png 3.5x, ads/320/rxbtutorial400.png 4x"><source media="(max-width: 500px)" srcset="ads/360/rxbtutorial100.png 1x, ads/360/rxbtutorial150.png 1.5x, ads/360/rxbtutorial200.png 2x, ads/360/rxbtutorial250.png 2.5x, ads/360/rxbtutorial300.png 3x, ads/360/rxbtutorial350.png 3.5x, ads/360/rxbtutorial400.png 4x"><source media="(max-width: 660px)" srcset="ads/480/rxbtutorial100.png 1x, ads/480/rxbtutorial150.png 1.5x, ads/480/rxbtutorial200.png 2x, ads/480/rxbtutorial250.png 2.5x, ads/480/rxbtutorial300.png 3x, ads/480/rxbtutorial350.png 3.5x, ads/480/rxbtutorial400.png 4x"><source media="(max-width: 747px)" srcset="ads/640/rxbtutorial100.png 1x, ads/640/rxbtutorial150.png 1.5x, ads/640/rxbtutorial200.png 2x, ads/640/rxbtutorial250.png 2.5x, ads/640/rxbtutorial300.png 3x, ads/640/rxbtutorial350.png 3.5x, ads/640/rxbtutorial400.png 4x"><img src="ads/728/rxbtutorial100.png" srcset="ads/728/rxbtutorial100.png 1x, ads/728/rxbtutorial125.png 1.25x, ads/728/rxbtutorial150.png 1.5x, ads/728/rxbtutorial175.png 1.75x, ads/728/rxbtutorial200.png 2x, ads/728/rxbtutorial250.png 2.5x, ads/728/rxbtutorial300.png 3x, ads/728/rxbtutorial350.png 3.5x, ads/728/rxbtutorial400.png 4x" alt="RegexBuddy—Better than a regular expression tutorial!"></picture></A></div> <div class=bulb><h1>Unicode Regular Expressions</h1><script type="text/javascript">showbulb();</script></div> <p>Unicode is a character set that aims to define all characters and glyphs from all human languages, living and dead. With more and more software being required to support multiple languages, or even just <i>any</i> language, Unicode has been strongly gaining popularity in recent years. Using different character sets for different languages is simply too cumbersome for programmers and users.</p> <p>Unfortunately, Unicode brings its own requirements and pitfalls when it comes to regular expressions. Of the regex flavors discussed in this tutorial, <A HREF="java.html" TARGET="_top">Java</A>, <A HREF="xml.html" TARGET="_top">XML</A> and <A HREF="dotnet.html" TARGET="_top">.NET</A> use Unicode-based regex engines. <A HREF="perl.html" TARGET="_top">Perl</A> supports Unicode starting with version 5.6. <A HREF="pcre.html" TARGET="_top">PCRE</A> can optionally be <a href="pcre.html#supportucp">compiled with Unicode support</a>. Note that PCRE is far less flexible in what it allows for the <tt>\p</tt> tokens, despite its name “Perl-compatible”. The <a href="php.html#preg">PHP preg functions</a>, which are based on PCRE, support Unicode when the /u option is appended to the regular expression. <A HREF="ruby.html" TARGET="_top">Ruby</A> supports Unicode escapes and properties in regular expressions starting with version 1.9. <A HREF="xregexp.html" TARGET="_top">XRegExp</A> brings support for Unicode properties to JavaScript.</p> <p><A HREF="regexbuddy.html" TARGET="_top">RegexBuddy’s regex engine</A> is fully Unicode-based starting with version 2.0.0. RegexBuddy 1.x.x did not support Unicode at all. <A HREF="powergrep.html" TARGET="_top">PowerGREP</A> uses the same Unicode regex engine starting with version 3.0.0. Earlier versions would convert Unicode files to ANSI prior to grepping with an 8-bit (i.e. non-Unicode) regex engine. <A HREF="editpadpro.html" TARGET="_top">EditPad Pro</A> supports Unicode starting with version 6.0.0.</p> <h2>Characters, Code Points, and Graphemes or How Unicode Makes a Mess of Things</h2> <p>Most people would consider <tt class=string>à</tt> a single character. Unfortunately, it need not be depending on the meaning of the word “character”.</p> <p>All Unicode regex engines discussed in this tutorial treat any single Unicode <i>code point</i> as a single character. When this tutorial tells you that <A HREF="dot.html" TARGET="_top">the dot matches any single character</A>, this translates into Unicode parlance as “the dot matches any single Unicode code point”. In Unicode, <tt class=string>à</tt> can be encoded as two code points: U+0061 (a) followed by U+0300 (grave accent). In this situation, <TT CLASS=syntax><SPAN CLASS="regexspecial">.</SPAN></TT> applied to <tt class=string>à</tt> will match <tt class=match>a</tt> without the accent. <TT CLASS=syntax><SPAN CLASS="regexspecial">^</SPAN><SPAN CLASS="regexspecial">.</SPAN><SPAN CLASS="regexspecial">$</SPAN></TT> will fail to match, since the string consists of two code points. <TT CLASS=syntax><SPAN CLASS="regexspecial">^</SPAN><SPAN CLASS="regexspecial">.</SPAN><SPAN CLASS="regexspecial">.</SPAN><SPAN CLASS="regexspecial">$</SPAN></TT> matches <tt class=match>à</tt>.</p> <p>The Unicode code point U+0300 (grave accent) is a <i>combining mark</i>. Any code point that is not a combining mark can be followed by any number of combining marks. This sequence, like U+0061 U+0300 above, is displayed as a single <i>grapheme</i> on the screen.</p> <p>Unfortunately, <tt class=string>à</tt> can also be encoded with the single Unicode code point U+00E0 (a with grave accent). The reason for this duality is that many historical character sets encode “a with grave accent” as a single character. Unicode’s designers thought it would be useful to have a one-on-one mapping with popular legacy character sets, in addition to the Unicode way of separating marks and base letters (which makes arbitrary combinations not supported by legacy character sets possible).</p> <a name="grapheme"></a><h2>How to Match a Single Unicode Grapheme</h2> <p>Matching a single grapheme, whether it’s encoded as a single code point, or as multiple code points using combining marks, is easy in Perl, PCRE, PHP, Boost, Ruby 2.0, Java 9, and the Just Great Software applications: simply use <TT CLASS=syntax><SPAN CLASS="regexspecial">\X</SPAN></TT>. You can consider <TT CLASS=syntax><SPAN CLASS="regexspecial">\X</SPAN></TT> the Unicode version of <A HREF="dot.html" TARGET="_top">the dot</A>. There is one difference, though: <TT CLASS=syntax><SPAN CLASS="regexspecial">\X</SPAN></TT> always matches line break characters, whereas the dot does not match line break characters unless you enable the <A HREF="modifiers.html" TARGET="_top">dot matches newline matching mode</A>.</p> <p>In .NET, Java 8 and prior, and Ruby 1.9 you can use <TT CLASS=syntax><SPAN CLASS="regexspecial">\P{M}</SPAN><SPAN CLASS="regexspecial">\p{M}</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexspecial">+</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexnest1">(?&gt;</SPAN><SPAN CLASS="regexspecial">\P{M}</SPAN><SPAN CLASS="regexspecial">\p{M}</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexnest1">)</SPAN></TT> as a reasonably close substitute. To match any number of graphemes, use <TT CLASS=syntax><SPAN CLASS="regexnest1">(?&gt;</SPAN><SPAN CLASS="regexspecial">\P{M}</SPAN><SPAN CLASS="regexspecial">\p{M}</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexnest1">)</SPAN><SPAN CLASS="regexspecial">+</SPAN></TT> as a substitute for <TT CLASS=syntax><SPAN CLASS="regexspecial">\X</SPAN><SPAN CLASS="regexspecial">+</SPAN></TT>.</p> <a name="codepoint"></a><h2>Matching a Specific Code Point</h2> <p>To match a specific Unicode code point, use <TT CLASS=syntax><SPAN CLASS="regexspecial">\uFFFF</SPAN></TT> where FFFF is the hexadecimal number of the code point you want to match. You must always specify 4 hexadecimal digits E.g. <TT CLASS=syntax><SPAN CLASS="regexspecial">\u00E0</SPAN></TT> matches <tt class=match>à</tt>, but only when encoded as a single code point U+00E0.</p> <p><A HREF="perl.html" TARGET="_top">Perl</A>, <A HREF="pcre.html" TARGET="_top">PCRE</A>, <A HREF="boost.html" TARGET="_top">Boost</A>, and <A HREF="stdregex.html" TARGET="_top">std::regex</A> do not support the <TT CLASS=syntax><SPAN CLASS="regexspecial">\uFFFF</SPAN></TT> syntax. They use <TT CLASS=syntax><SPAN CLASS="regexspecial">\x{FFFF}</SPAN></TT> instead. You can omit leading zeros in the hexadecimal number between the curly braces. Since <tt>\x</tt> by itself is not a valid regex token, <TT CLASS=syntax><SPAN CLASS="regexspecial">\x{1234}</SPAN></TT> can never be confused to match <tt>\x</tt> 1234 times. It always matches the Unicode code point U+1234. <TT CLASS=syntax><SPAN CLASS="regexspecial">\x{1234}</SPAN><SPAN CLASS="regexspecial">{5678}</SPAN></TT> will try to match code point U+1234 exactly 5678 times.</p> <p>In Java, the regex token <TT CLASS=syntax><SPAN CLASS="regexspecial">\uFFFF</SPAN></TT> only matches the specified code point, even when you turned on canonical equivalence. However, the same syntax <tt>\uFFFF</tt> is also used to insert Unicode characters into literal strings in the Java source code. <tt>Pattern.compile(&quot;\u00E0&quot;)</tt> will match both the single-code-point and double-code-point encodings of <tt class=match>à</tt>, while <tt>Pattern.compile(&quot;\\u00E0&quot;)</tt> matches only the single-code-point version. Remember that when writing a regex as a Java string literal, backslashes must be escaped. The former Java code compiles the regex <TT CLASS=syntax><SPAN CLASS="regexplain">à</SPAN></TT>, while the latter compiles <TT CLASS=syntax><SPAN CLASS="regexspecial">\u00E0</SPAN></TT>. Depending on what you’re doing, the difference may be significant.</p> <p><A HREF="javascript.html" TARGET="_top">JavaScript</A>, which does not offer any Unicode support through its RegExp class, does support <TT CLASS=syntax><SPAN CLASS="regexspecial">\uFFFF</SPAN></TT> for matching a single Unicode code point as part of its string syntax.</p> <p><A HREF="xml.html" TARGET="_top">XML Schema</A> and <A HREF="xpath.html" TARGET="_top">XPath</A> do not have a regex token for matching Unicode code points. However, you can easily use XML entities like <tt>&amp;#xFFFF;</tt> to insert literal code points into your regular expression.</p> <a name="category"></a><h2>Unicode Categories</h2> <p>In addition to complications, Unicode also brings new possibilities. One is that each Unicode character belongs to a certain category. You can match a single character belonging to the “letter” category with <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{L}</SPAN></TT>. You can match a single character <i>not</i> belonging to that category with <TT CLASS=syntax><SPAN CLASS="regexspecial">\P{L}</SPAN></TT>.</p> <p>Again, “character” really means “Unicode code point”. <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{L}</SPAN></TT> matches a single code point in the category “letter”. If your input string is <tt class=string>à</tt> encoded as U+0061 U+0300, it matches <tt class=match>a</tt> without the accent. If the input is <tt class=string>à</tt> encoded as U+00E0, it matches <tt class=match>à</tt> with the accent. The reason is that both the code points U+0061 (a) and U+00E0 (à) are in the category “letter”, while U+0300 is in the category “mark”.</p> <p>You should now understand why <TT CLASS=syntax><SPAN CLASS="regexspecial">\P{M}</SPAN><SPAN CLASS="regexspecial">\p{M}</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexspecial">+</SPAN></TT> is the equivalent of <TT CLASS=syntax><SPAN CLASS="regexspecial">\X</SPAN></TT>. <TT CLASS=syntax><SPAN CLASS="regexspecial">\P{M}</SPAN></TT> matches a code point that is not a combining mark, while <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{M}</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexspecial">+</SPAN></TT> matches <A HREF="repeat.html" TARGET="_top">zero or more</A> code points that are combining marks. To match a letter including any diacritics, use <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{L}</SPAN><SPAN CLASS="regexspecial">\p{M}</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexspecial">+</SPAN></TT>. This last regex will always match <tt class=match>à</tt>, regardless of how it is encoded. The <A HREF="possessive.html" TARGET="_top">possessive quantifier</A> makes sure that backtracking doesn’t cause <TT CLASS=syntax><SPAN CLASS="regexspecial">\P{M}</SPAN><SPAN CLASS="regexspecial">\p{M}</SPAN><SPAN CLASS="regexspecial">*</SPAN><SPAN CLASS="regexspecial">+</SPAN></TT> to match a non-mark without the combining marks that follow it, which <TT CLASS=syntax><SPAN CLASS="regexspecial">\X</SPAN></TT> would never do.</p> <p>PCRE, PHP, and .NET are case sensitive when it checks the part between curly braces of a <tt>\p</tt> token. <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Zs}</SPAN></TT> will match any kind of space character, while <TT CLASS=syntax><SPAN CLASS="regexerr">\p{zs}</SPAN></TT> will throw an error. All other regex engines described in this tutorial will match the space in both cases, ignoring the case of the category between the curly braces. Still, I recommend you make a habit of using the same uppercase and lowercase combination as I did in the list of properties below. This will make your regular expressions work with all Unicode regex engines.</p> <p>In addition to the standard notation, <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{L}</SPAN></TT>, Java, Perl, PCRE, the <A HREF="jgsoft.html" TARGET="_top">JGsoft engine</A>, and XRegExp 3 allow you to use the shorthand <TT CLASS=syntax><SPAN CLASS="regexspecial">\pL</SPAN></TT>. The shorthand only works with single-letter Unicode properties. <TT CLASS=syntax><SPAN CLASS="regexspecial">\pL</SPAN><SPAN CLASS="regexplain">l</SPAN></TT> is <i>not</i> the equivalent of <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Ll}</SPAN></TT>. It is the equivalent of <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{L}</SPAN><SPAN CLASS="regexplain">l</SPAN></TT> which matches <tt class=match>Al</tt> or <tt class=match>àl</tt> or any Unicode letter followed by a literal <tt class=match>l</tt>.</p> <p>Perl, XRegExp, and the JGsoft engine also support the longhand <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Letter}</SPAN></TT>. You can find a complete list of all Unicode properties below. You may omit the underscores or use hyphens or spaces instead.</p> <ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{L}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Letter}</SPAN></TT>: any kind of letter from any language. <ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Ll}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Lowercase_Letter}</SPAN></TT>: a lowercase letter that has an uppercase variant. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Lu}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Uppercase_Letter}</SPAN></TT>: an uppercase letter that has a lowercase variant. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Lt}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Titlecase_Letter}</SPAN></TT>: a letter that appears at the start of a word when only the first letter of the word is capitalized. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{L&amp;}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Cased_Letter}</SPAN></TT>: a letter that exists in lowercase and uppercase variants (combination of Ll, Lu and Lt). <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Lm}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Modifier_Letter}</SPAN></TT>: a special character that is used like a letter. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Lo}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Other_Letter}</SPAN></TT>: a letter or ideograph that does not have lowercase and uppercase variants. </ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{M}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Mark}</SPAN></TT>: a character intended to be combined with another character (e.g. accents, umlauts, enclosing boxes, etc.). <ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Mn}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Non_Spacing_Mark}</SPAN></TT>: a character intended to be combined with another character without taking up extra space (e.g. accents, umlauts, etc.). <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Mc}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Spacing_Combining_Mark}</SPAN></TT>: a character intended to be combined with another character that takes up extra space (vowel signs in many Eastern languages). <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Me}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Enclosing_Mark}</SPAN></TT>: a character that encloses the character it is combined with (circle, square, keycap, etc.). </ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Z}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Separator}</SPAN></TT>: any kind of whitespace or invisible separator. <ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Zs}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Space_Separator}</SPAN></TT>: a whitespace character that is invisible, but does take up space. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Zl}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Line_Separator}</SPAN></TT>: line separator character U+2028. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Zp}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Paragraph_Separator}</SPAN></TT>: paragraph separator character U+2029. </ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{S}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Symbol}</SPAN></TT>: math symbols, currency signs, dingbats, box-drawing characters, etc. <ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Sm}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Math_Symbol}</SPAN></TT>: any mathematical symbol. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Sc}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Currency_Symbol}</SPAN></TT>: any currency sign. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Sk}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Modifier_Symbol}</SPAN></TT>: a combining character (mark) as a full character on its own. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{So}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Other_Symbol}</SPAN></TT>: various symbols that are not math symbols, currency signs, or combining characters. </ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{N}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Number}</SPAN></TT>: any kind of numeric character in any script. <ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Nd}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Decimal_Digit_Number}</SPAN></TT>: a digit zero through nine in any script except ideographic scripts. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Nl}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Letter_Number}</SPAN></TT>: a number that looks like a letter, such as a Roman numeral. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{No}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Other_Number}</SPAN></TT>: a superscript or subscript digit, or a number that is not a digit 0–9 (excluding numbers from ideographic scripts). </ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{P}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Punctuation}</SPAN></TT>: any kind of punctuation character. <ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Pd}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Dash_Punctuation}</SPAN></TT>: any kind of hyphen or dash. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Ps}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Open_Punctuation}</SPAN></TT>: any kind of opening bracket. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Pe}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Close_Punctuation}</SPAN></TT>: any kind of closing bracket. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Pi}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Initial_Punctuation}</SPAN></TT>: any kind of opening quote. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Pf}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Final_Punctuation}</SPAN></TT>: any kind of closing quote. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Pc}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Connector_Punctuation}</SPAN></TT>: a punctuation character such as an underscore that connects words. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Po}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Other_Punctuation}</SPAN></TT>: any kind of punctuation character that is not a dash, bracket, quote or connector. </ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{C}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Other}</SPAN></TT>: invisible control characters and unused code points. <ul> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Cc}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Control}</SPAN></TT>: an ASCII or Latin-1 control character: 0x00–0x1F and 0x7F–0x9F. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Cf}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Format}</SPAN></TT>: invisible formatting indicator. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Co}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Private_Use}</SPAN></TT>: any code point reserved for private use. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Cs}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Surrogate}</SPAN></TT>: one half of a surrogate pair in UTF-16 encoding. <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Cn}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Unassigned}</SPAN></TT>: any code point to which no character has been assigned. </ul> </ul> <a name="script"></a><h2>Unicode Scripts</h2> <p>The Unicode standard places each assigned code point (character) into one script. A script is a group of code points used by a particular human writing system. Some scripts like <tt>Thai</tt> correspond with a single human language. Other scripts like <tt>Latin</tt> span multiple languages.</p> <p>Some languages are composed of multiple scripts. There is no Japanese Unicode script. Instead, Unicode offers the <tt>Hiragana</tt>, <tt>Katakana</tt>, <tt>Han</tt>, and <tt>Latin</tt> scripts that Japanese documents are usually composed of.</p> <p>A special script is the <tt>Common</tt> script. This script contains all sorts of characters that are common to a wide range of scripts. It includes all sorts of punctuation, whitespace and miscellaneous symbols.</p> <p>All assigned Unicode code points (those matched by <TT CLASS=syntax><SPAN CLASS="regexspecial">\P{Cn}</SPAN></TT>) are part of exactly one Unicode script. All unassigned Unicode code points (those matched by <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Cn}</SPAN></TT>) are not part of any Unicode script at all.</p> <p>The <A HREF="jgsoft.html" TARGET="_top">JGsoft engine</A>, <A HREF="perl.html" TARGET="_top">Perl</A>, <A HREF="pcre.html" TARGET="_top">PCRE</A>, <A HREF="php.html" TARGET="_top">PHP</A>, <A HREF="ruby.html" TARGET="_top">Ruby 1.9</A>, <A HREF="delphi.html" TARGET="_top">Delphi</A>, and <A HREF="xregexp.html" TARGET="_top">XRegExp</A> can match Unicode scripts. Here’s a list:</p> <ol> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Common}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Arabic}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Armenian}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Bengali}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Bopomofo}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Braille}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Buhid}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Canadian_Aboriginal}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Cherokee}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Cyrillic}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Devanagari}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Ethiopic}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Georgian}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Greek}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Gujarati}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Gurmukhi}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Han}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Hangul}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Hanunoo}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Hebrew}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Hiragana}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Inherited}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Kannada}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Katakana}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Khmer}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Lao}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Latin}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Limbu}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Malayalam}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Mongolian}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Myanmar}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Ogham}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Oriya}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Runic}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Sinhala}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Syriac}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Tagalog}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Tagbanwa}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{TaiLe}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Tamil}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Telugu}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Thaana}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Thai}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Tibetan}</SPAN></TT> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Yi}</SPAN></TT> </ol> <p>Perl and the JGsoft flavor allow you to use <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{IsLatin}</SPAN></TT> instead of <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Latin}</SPAN></TT>. The “Is” syntax is useful for distinguishing between scripts and blocks, as explained in the next section. PCRE, PHP, and XRegExp do not support the “Is” prefix.</p> <p>Java 7 adds support for Unicode scripts. Unlike the other flavors, Java 7 requires the “Is” prefix.</p> <a name="block"></a><h2>Unicode Blocks</h2> <p>The Unicode standard divides the Unicode character map into different blocks or ranges of code points. Each block is used to define characters of a particular script like “Tibetan” or belonging to a particular group like “Braille Patterns”. Most blocks include unassigned code points, reserved for future expansion of the Unicode standard.</p> <p>Note that Unicode blocks do not correspond 100% with scripts. An essential difference between blocks and scripts is that a block is a single contiguous range of code points, as listed below. Scripts consist of characters taken from all over the Unicode character map. Blocks may include unassigned code points (i.e. code points matched by <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Cn}</SPAN></TT>). Scripts never include unassigned code points. Generally, if you’re not sure whether to use a Unicode script or Unicode block, use the script.</p> <p>For example, the Currency block does not include the dollar and yen symbols. Those are found in the Basic_Latin and Latin-1_Supplement blocks instead, even though both are currency symbols, and the yen symbol is not a Latin character. This is for historical reasons, because the ASCII standard includes the dollar sign, and the ISO-8859 standard includes the yen sign. You should not blindly use any of the blocks listed below based on their names. Instead, look at the ranges of characters they actually match. A tool like <A HREF="regexbuddy.html" TARGET="_top">RegexBuddy</A> can be very helpful with this. The Unicode property <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Sc}</SPAN></TT> or <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{Currency_Symbol}</SPAN></TT> would be a better choice than the Unicode block <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCurrency_Symbols}</SPAN></TT> when trying to find all currency symbols.</p> <ol> <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InBasic_Latin}</SPAN></TT>: U+0000–U+007F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InLatin-1_Supplement}</SPAN></TT>: U+0080–U+00FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InLatin_Extended-A}</SPAN></TT>: U+0100–U+017F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InLatin_Extended-B}</SPAN></TT>: U+0180–U+024F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InIPA_Extensions}</SPAN></TT>: U+0250–U+02AF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InSpacing_Modifier_Letters}</SPAN></TT>: U+02B0–U+02FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCombining_Diacritical_Marks}</SPAN></TT>: U+0300–U+036F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InGreek_and_Coptic}</SPAN></TT>: U+0370–U+03FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCyrillic}</SPAN></TT>: U+0400–U+04FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCyrillic_Supplementary}</SPAN></TT>: U+0500–U+052F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InArmenian}</SPAN></TT>: U+0530–U+058F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InHebrew}</SPAN></TT>: U+0590–U+05FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InArabic}</SPAN></TT>: U+0600–U+06FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InSyriac}</SPAN></TT>: U+0700–U+074F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InThaana}</SPAN></TT>: U+0780–U+07BF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InDevanagari}</SPAN></TT>: U+0900–U+097F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InBengali}</SPAN></TT>: U+0980–U+09FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InGurmukhi}</SPAN></TT>: U+0A00–U+0A7F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InGujarati}</SPAN></TT>: U+0A80–U+0AFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InOriya}</SPAN></TT>: U+0B00–U+0B7F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InTamil}</SPAN></TT>: U+0B80–U+0BFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InTelugu}</SPAN></TT>: U+0C00–U+0C7F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InKannada}</SPAN></TT>: U+0C80–U+0CFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InMalayalam}</SPAN></TT>: U+0D00–U+0D7F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InSinhala}</SPAN></TT>: U+0D80–U+0DFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InThai}</SPAN></TT>: U+0E00–U+0E7F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InLao}</SPAN></TT>: U+0E80–U+0EFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InTibetan}</SPAN></TT>: U+0F00–U+0FFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InMyanmar}</SPAN></TT>: U+1000–U+109F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InGeorgian}</SPAN></TT>: U+10A0–U+10FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InHangul_Jamo}</SPAN></TT>: U+1100–U+11FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InEthiopic}</SPAN></TT>: U+1200–U+137F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCherokee}</SPAN></TT>: U+13A0–U+13FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InUnified_Canadian_Aboriginal_Syllabics}</SPAN></TT>: U+1400–U+167F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InOgham}</SPAN></TT>: U+1680–U+169F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InRunic}</SPAN></TT>: U+16A0–U+16FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InTagalog}</SPAN></TT>: U+1700–U+171F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InHanunoo}</SPAN></TT>: U+1720–U+173F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InBuhid}</SPAN></TT>: U+1740–U+175F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InTagbanwa}</SPAN></TT>: U+1760–U+177F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InKhmer}</SPAN></TT>: U+1780–U+17FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InMongolian}</SPAN></TT>: U+1800–U+18AF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InLimbu}</SPAN></TT>: U+1900–U+194F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InTai_Le}</SPAN></TT>: U+1950–U+197F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InKhmer_Symbols}</SPAN></TT>: U+19E0–U+19FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InPhonetic_Extensions}</SPAN></TT>: U+1D00–U+1D7F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InLatin_Extended_Additional}</SPAN></TT>: U+1E00–U+1EFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InGreek_Extended}</SPAN></TT>: U+1F00–U+1FFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InGeneral_Punctuation}</SPAN></TT>: U+2000–U+206F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InSuperscripts_and_Subscripts}</SPAN></TT>: U+2070–U+209F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCurrency_Symbols}</SPAN></TT>: U+20A0–U+20CF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCombining_Diacritical_Marks_for_Symbols}</SPAN></TT>: U+20D0–U+20FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InLetterlike_Symbols}</SPAN></TT>: U+2100–U+214F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InNumber_Forms}</SPAN></TT>: U+2150–U+218F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InArrows}</SPAN></TT>: U+2190–U+21FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InMathematical_Operators}</SPAN></TT>: U+2200–U+22FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InMiscellaneous_Technical}</SPAN></TT>: U+2300–U+23FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InControl_Pictures}</SPAN></TT>: U+2400–U+243F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InOptical_Character_Recognition}</SPAN></TT>: U+2440–U+245F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InEnclosed_Alphanumerics}</SPAN></TT>: U+2460–U+24FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InBox_Drawing}</SPAN></TT>: U+2500–U+257F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InBlock_Elements}</SPAN></TT>: U+2580–U+259F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InGeometric_Shapes}</SPAN></TT>: U+25A0–U+25FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InMiscellaneous_Symbols}</SPAN></TT>: U+2600–U+26FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InDingbats}</SPAN></TT>: U+2700–U+27BF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InMiscellaneous_Mathematical_Symbols-A}</SPAN></TT>: U+27C0–U+27EF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InSupplemental_Arrows-A}</SPAN></TT>: U+27F0–U+27FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InBraille_Patterns}</SPAN></TT>: U+2800–U+28FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InSupplemental_Arrows-B}</SPAN></TT>: U+2900–U+297F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InMiscellaneous_Mathematical_Symbols-B}</SPAN></TT>: U+2980–U+29FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InSupplemental_Mathematical_Operators}</SPAN></TT>: U+2A00–U+2AFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InMiscellaneous_Symbols_and_Arrows}</SPAN></TT>: U+2B00–U+2BFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCJK_Radicals_Supplement}</SPAN></TT>: U+2E80–U+2EFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InKangxi_Radicals}</SPAN></TT>: U+2F00–U+2FDF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InIdeographic_Description_Characters}</SPAN></TT>: U+2FF0–U+2FFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCJK_Symbols_and_Punctuation}</SPAN></TT>: U+3000–U+303F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InHiragana}</SPAN></TT>: U+3040–U+309F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InKatakana}</SPAN></TT>: U+30A0–U+30FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InBopomofo}</SPAN></TT>: U+3100–U+312F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InHangul_Compatibility_Jamo}</SPAN></TT>: U+3130–U+318F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InKanbun}</SPAN></TT>: U+3190–U+319F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InBopomofo_Extended}</SPAN></TT>: U+31A0–U+31BF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InKatakana_Phonetic_Extensions}</SPAN></TT>: U+31F0–U+31FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InEnclosed_CJK_Letters_and_Months}</SPAN></TT>: U+3200–U+32FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCJK_Compatibility}</SPAN></TT>: U+3300–U+33FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCJK_Unified_Ideographs_Extension_A}</SPAN></TT>: U+3400–U+4DBF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InYijing_Hexagram_Symbols}</SPAN></TT>: U+4DC0–U+4DFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCJK_Unified_Ideographs}</SPAN></TT>: U+4E00–U+9FFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InYi_Syllables}</SPAN></TT>: U+A000–U+A48F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InYi_Radicals}</SPAN></TT>: U+A490–U+A4CF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InHangul_Syllables}</SPAN></TT>: U+AC00–U+D7AF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InHigh_Surrogates}</SPAN></TT>: U+D800–U+DB7F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InHigh_Private_Use_Surrogates}</SPAN></TT>: U+DB80–U+DBFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InLow_Surrogates}</SPAN></TT>: U+DC00–U+DFFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InPrivate_Use_Area}</SPAN></TT>: U+E000–U+F8FF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCJK_Compatibility_Ideographs}</SPAN></TT>: U+F900–U+FAFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InAlphabetic_Presentation_Forms}</SPAN></TT>: U+FB00–U+FB4F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InArabic_Presentation_Forms-A}</SPAN></TT>: U+FB50–U+FDFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InVariation_Selectors}</SPAN></TT>: U+FE00–U+FE0F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCombining_Half_Marks}</SPAN></TT>: U+FE20–U+FE2F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InCJK_Compatibility_Forms}</SPAN></TT>: U+FE30–U+FE4F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InSmall_Form_Variants}</SPAN></TT>: U+FE50–U+FE6F <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InArabic_Presentation_Forms-B}</SPAN></TT>: U+FE70–U+FEFF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InHalfwidth_and_Fullwidth_Forms}</SPAN></TT>: U+FF00–U+FFEF <li><TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InSpecials}</SPAN></TT>: U+FFF0–U+FFFF </ol> <p>Not all Unicode regex engines use the same syntax to match Unicode blocks. <A HREF="java.html" TARGET="_top">Java</A>, <A HREF="ruby.html" TARGET="_top">Ruby 2.0</A>, and <A HREF="xregexp.html" TARGET="_top">XRegExp</A> use the <tt>\p{InBlock}</tt> syntax as listed above. <A HREF="dotnet.html" TARGET="_top">.NET</A> and <A HREF="xml.html" TARGET="_top">XML</A> use <tt>\p{IsBlock}</tt> instead. <A HREF="perl.html" TARGET="_top">Perl</A> and the <A HREF="jgsoft.html" TARGET="_top">JGsoft flavor</A> support both notations. I recommend you use the “In” notation if your regex engine supports it. “In” can only be used for Unicode blocks, while “Is” can also be used for Unicode properties and scripts, depending on the regular expression flavor you’re using. By using “In”, it’s obvious you’re matching a block and not a similarly named property or script.</p> <p>In .NET and XML, you must omit the underscores but keep the hyphens in the block names. E.g. Use <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{IsLatinExtended-A}</SPAN></TT> instead of <TT CLASS=syntax><SPAN CLASS="regexspecial">\p{InLatin_Extended-A}</SPAN></TT>. In Java, you must omit the hyphens. .NET and XML also compare the names case sensitively, while Perl, Ruby, and the JGsoft flavor compare them case insensitively. Java 4 is case sensitive. Java 5 and later are case sensitive for the “Is” prefix but not for the block names themselves.</p> <p>The actual names of the blocks are the same in all regular expression engines. The block names are defined in the Unicode standard. PCRE and PHP do not support Unicode blocks, even though they support Unicode scripts.</p> <h2>Do You Need To Worry About Different Encodings?</h2> <p>While you should always keep in mind the pitfalls created by the different ways in which accented characters can be encoded, you don’t always have to worry about them. If you know that your input string and your regex use the same style, then you don’t have to worry about it at all. This process is called Unicode <i>normalization</i>. All programming languages with native Unicode support, such as Java, C# and VB.NET, have library routines for normalizing strings. If you normalize both the subject and regex before attempting the match, there won’t be any inconsistencies.</p> <p>If you are using Java, you can pass the CANON_EQ flag as the second parameter to Pattern.compile(). This tells the Java regex engine to consider <i>canonically equivalent</i> characters as identical. The regex <TT CLASS=syntax><SPAN CLASS="regexplain">à</SPAN></TT> encoded as U+00E0 matches <tt class=match>à</tt> encoded as U+0061 U+0300, and vice versa. None of the other regex engines currently support canonical equivalence while matching.</p> <p>If you type the à key on the keyboard, all word processors that I know of will insert the code point U+00E0 into the file. So if you’re working with text that you typed in yourself, any regex that you type in yourself will match in the same way.</p> <p>Finally, if you’re using <A HREF="powergrep.html" TARGET="_top">PowerGREP</A> to search through text files encoded using a traditional Windows (often called “ANSI”) or ISO-8859 code page, PowerGREP always uses the one-on-one substitution. Since all the Windows or ISO-8859 code pages encode accented characters as a single code point, nearly all software uses a single Unicode code point for each character when converting the file to Unicode.</p> <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='tutorial.html'>Introduction</a>&ensp;|&ensp;<a href='tutorialcnt.html'>Table of Contents</a>&ensp;|&ensp;<a href='characters.html'>Special Characters</a>&ensp;|&ensp;<a href='nonprint.html'>Non-Printable Characters</a>&ensp;|&ensp;<a href='engine.html'>Regex Engine Internals</a>&ensp;|&ensp;<a href='charclass.html'>Character Classes</a>&ensp;|&ensp;<a href='charclasssubtract.html'>Character Class Subtraction</a>&ensp;|&ensp;<a href='charclassintersect.html'>Character Class Intersection</a>&ensp;|&ensp;<a href='shorthand.html'>Shorthand Character Classes</a>&ensp;|&ensp;<a href='dot.html'>Dot</a>&ensp;|&ensp;<a href='anchors.html'>Anchors</a>&ensp;|&ensp;<a href='wordboundaries.html'>Word Boundaries</a>&ensp;|&ensp;<a href='alternation.html'>Alternation</a>&ensp;|&ensp;<a href='optional.html'>Optional Items</a>&ensp;|&ensp;<a href='repeat.html'>Repetition</a>&ensp;|&ensp;<a href='brackets.html'>Grouping &amp; Capturing</a>&ensp;|&ensp;<a href='backref.html'>Backreferences</a>&ensp;|&ensp;<a href='backref2.html'>Backreferences, part 2</a>&ensp;|&ensp;<a href='named.html'>Named Groups</a>&ensp;|&ensp;<a href='backrefrel.html'>Relative Backreferences</a>&ensp;|&ensp;<a href='branchreset.html'>Branch Reset Groups</a>&ensp;|&ensp;<a href='freespacing.html'>Free-Spacing &amp; Comments</a>&ensp;|&ensp;<a href='unicode.html'>Unicode</a>&ensp;|&ensp;<a href='modifiers.html'>Mode Modifiers</a>&ensp;|&ensp;<a href='atomic.html'>Atomic Grouping</a>&ensp;|&ensp;<a href='possessive.html'>Possessive Quantifiers</a>&ensp;|&ensp;<a href='lookaround.html'>Lookahead &amp; Lookbehind</a>&ensp;|&ensp;<a href='lookaround2.html'>Lookaround, part 2</a>&ensp;|&ensp;<a href='keep.html'>Keep Text out of The Match</a>&ensp;|&ensp;<a href='conditional.html'>Conditionals</a>&ensp;|&ensp;<a href='balancing.html'>Balancing Groups</a>&ensp;|&ensp;<a href='recurse.html'>Recursion</a>&ensp;|&ensp;<a href='subroutine.html'>Subroutines</a>&ensp;|&ensp;<a href='recurseinfinite.html'>Infinite Recursion</a>&ensp;|&ensp;<a href='recurserepeat.html'>Recursion &amp; Quantifiers</a>&ensp;|&ensp;<a href='recursecapture.html'>Recursion &amp; Capturing</a>&ensp;|&ensp;<a href='recursebackref.html'>Recursion &amp; Backreferences</a>&ensp;|&ensp;<a href='recursebacktrack.html'>Recursion &amp; Backtracking</a>&ensp;|&ensp;<a href='posixbrackets.html'>POSIX Bracket Expressions</a>&ensp;|&ensp;<a href='zerolength.html'>Zero-Length Matches</a>&ensp;|&ensp;<a href='continue.html'>Continuing Matches</a>&ensp;|</p></div> <div id=copyright> <P CLASS=copyright>Page URL: <A HREF="https://www.regular-expressions.info/unicode.html" TARGET="_top">https://www.regular-expressions.info/unicode.html</A><BR> Page last updated: 12 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