Pattern 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
正則表達式的編譯表示。
[Android.Runtime.Register("java/util/regex/Pattern", DoNotGenerateAcw=true)]
public sealed class Pattern : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ISerializable
[<Android.Runtime.Register("java/util/regex/Pattern", DoNotGenerateAcw=true)>]
type Pattern = class
inherit Object
interface ISerializable
interface IJavaObject
interface IDisposable
interface IJavaPeerable
- 繼承
- 屬性
- 實作
備註
正則表達式的編譯表示。
指定為字串的正則表達式必須先編譯為這個類別的實例。 然後,您可以使用產生的模式來建立 Matcher 物件,該物件可以比對正則表達式的任意 java.lang.CharSequence 字元序列。 執行比對所涉及的所有狀態都位於比對器中,因此許多比對者可以共用相同的模式。
因此,典型的調用序列
<blockquote>
Pattern p = Pattern.{@link #compile compile}("a*b");
Matcher m = p.{@link #matcher matcher}("aaaaab");
boolean b = m.{@link Matcher#matches matches}();
</blockquote>
#matches matches當正則表達式只使用一次時,這個類別會將方法定義為方便使用的方法。 此方法會編譯表達式,並在單一調用中與它比對輸入序列。 陳述式
<blockquote>
boolean b = Pattern.matches("a*b", "aaaaab");
</blockquote>
相當於上述的三個語句,不過針對重複的相符專案,其效率較低,因為它不允許重複使用編譯的模式。
這個類別的實例是不可變的,而且可供多個並行線程使用。 類別的 Matcher 實例不適合這類使用。
<h2>“sum”>regular-expression constructs</h2 的摘要>
<table class=“borderless”><caption style=“display:none”>Regular expression constructs, and what match</caption><thead style=“text-align:left”><tr<>th id=“construct”construct</th><id=“matchs”>Matchs></th<>/tr<>/thead><tbody style=“text-align:left”>
<tr><th colspan=“2” style=“padding-top:20px” id=“characters”>Characters</th></tr>
<tr><th style=“vertical-align:top; font-weight: normal” id=“x”>x</th><td headers=“matches characters x”>The character x</td></tr tr th><<>style=“vertical-align:top; font-weight: normal” id=“backslash”><\\/th><td headers=“matches characters backslash”>The backslash character</td></tr tr><><th style=“vertical-align:top; font-weight: normal” id=“octal_n”>\0n</th><td headers=“比對字元octal_n”>具有八進位值的0字元 n (0 <= n <= 7)</td></tr tr><<>th style=“vertical-align:top; font-weight: normal” id=“octal_nn”\0>nn</th><td headers=“matches characters octal_nn”>字符與八進位值0 nn (0 <= n <= 7)/td/tr tr<>><th style=“vertical-align:top; font-weight: normal” id=“octal_nnn”>\0mnn/th><td headers=“符合字符octal_nnn”>具有八進位值的0字元 mnn< (0 <=><< m <= 3, 0 <= n <= 7)/td/tr tr>><<th style=“vertical-align:top; font-weight: normal” id=“hex_hh>\x”hh/th<>td headers=“matches characters hex_hh”>具有十六進位值的0x字符 hh<</td></tr tr<>><th style=“vertical-align:top; font-weight: normal” id=“hex_hhhh”>\uhhhh</th<>td headers=“matches characters hex_hhhh”>><<具有十六進位 的字元;value 0xhhhh</td></tr tr><<>th style=“vertical-align:top; font-weight: normal” id=“hex_h_h”>\x{h...h}</th><td headers=“符合字元hex_h_h”>具有十六進位值的0x字元 h...h (java.lang.Character#MIN_CODE_POINT Character.MIN_CODE_POINT <= 0xh...h <= java.lang.Character#MAX_CODE_POINT Character.MAX_CODE_POINT)</td></tr tr><><th style=“vertical-align:top; font-weight: normal” id=“unicode_name>\N{”name<}/th td headers=“matches characters unicode_name”>字符與 Unicode 字符名稱 'name'</td></tr tr<><>th style=“vertical-align:top; font-weight:normal” id=“tab”>\t</th>><<td headers=“符合字符索引卷標”>索引卷標character ('\u0009')</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“newline”><\n/th td headers=“matches characters newline”>The newline (line feed) character ('\u000A')</td></tr tr<>th><style=“vertical-align:top; font-weight:normal” id=“return”>\r</th><><td headers=“matches characters return”>The carriage-return character ('\u000D')</td></tr tr><<>th style=“vertical-align:top; font-weight:normal” id=“form_feed”><\f/th td headers=“matches characters form_feed”>the form-feed character ('\u000C')</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“bell”\a<>/th<<>>td headers=“matches characters bell”>The alert (bell) character ('\u0007')</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“escape”\e></th td headers=“matches characters escape”>The escape character ('\u001B')</td></tr tr th><<>style=“vertical-align:top; font-weight:normal” id=“ctrl_x”\c>x</th<>><td headers=“matches characters ctrl_x”>對應 x</td></tr 的控制字符>
<tr><th colspan=“2” style=“padding-top:20px” id=“classes”>Character classes</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“simple”><[abc]/th td headers=“matches classs simple”>a, bor (simple class)</td></tr<><>tr th style=“vertical-align:top; font-weight:normal” id=“negation”/th><<>td headers=“matches classs negation”>除了 、 b或 c c (negation><[^abc])</td></tr tr tr><>< 以外的a任何字符th style=“vertical-align:top;font-weight:normal“ id=”range“><[a-zA-Z]/th td headers=”matches classes range“>a through z or A through Z, inclusive (range)</td/tr tr<>><th style=”vertical-align:top; font-weight:normal“ id=”union“<>[a-d[m-p]]/th><><td>< headers=”matches classes union“>a 到 ,或m透過 pd: [a-dm-p] (union)</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”intersection“/th>td headers=”matches classes intersection“[a-z&&[def]]>d<>, e, or f (intersection)</tr<>tr><th style=”vertical-align:top; font-weight:normal“ id=”subtraction1“[a-z&&[^bc]]></th<>td headers=”matches classes subtraction1“>a 到 z,除了 和 [ad-z] c: b (減法)</td></tr tr><><<th style=“vertical-align:top;font-weight:normal“ id=”減法2“><[a-z&&[^m-p]]/th><td headers=”matches classes subtraction2“a> through z, not m through p: [a-lq-z](減法)</td></tr>
<tr><th colspan=“2” style=“padding-top:20px” id=“predef”>Predefined character classes</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“any”>.</th><td headers=“matchs predef any”>Any character (may or may or may not match line terminators)</td></tr tr th><<>style=“vertical-align:top; font-weight:normal” id=“digit”>\d</th><td headers=“matches predef digit”>A digit: \p{IsDigit}</td></tr tr<>><th style=“vertical-align:top; font-weight:normal” id=“non_digit”>\D</th><td headers=“matches predef non_digit”>A non-digit: [^\d]</td></tr tr<>><th style=“vertical-align:top; font-weight:normal” id=“horiz_white”<>\h/th<>td headers=“matches predef horiz_white”>A horizontal whitespace character: [ \t\xA0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000]</td></tr tr><<>th style=“vertical-align:top; font-weight:normal” id=“non_horiz_white”\H<>/th><td headers=”符合 predef non_horiz_white“>非水準空格符:<[^\h] /td></tr tr><><th style=”vertical-align:top; font-weight:normal“ id=”white“>\s</th><td headers=”matches predef white“>A whitespace character: \p{IsWhite_Space}</td></tr tr><><th style=”vertical-align:top; font-weight:normal“ id=”non_white“>\S</th><td headers=”matches predef non_white“A>非空格符: [^\s]/td></tr tr><<>th style=“vertical-align:top; font-weight:normal” id=“vert_white”><\v/th td headers=“matches predef vert_white”>A vertical空格符:<[\n\x0B\f\r\x85\u2028\u2029] /td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“non_vert_white”<>\V/th><<>td headers=“matches predef non_vert_white”>A 非垂直空格符<character: [^\v]/td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“word”><\w/th><td headers=“matches predef word”>A word character: [\p{alpha\p{gc=Mark}\p{digit}\p{gc=Connector_Punctuation}\p{Join_Control}]}</td></tr<>tr tr><th style=“vertical-align:top; font-weight:normal” id=“non_word”<>\W/th<>td headers=“matches predef non_<word“>非單字字元: [^\w]</td></tr>
<tr><th colspan=“2” style=“padding-top:20px” id=“posix”><b>POSIX 字符類別 (Unicode-aware)</b></th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“Lower”\p{Lower>}</th td headers=“matches posix Lower”>A lower-case 字母字符: \p{IsLowercase}</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“Upper”\p{Upper>}</th><><td headers=“matches posix Upper”>An upper-case alphabetic character:\p{IsUppercase}</td></tr><tr th><style=“vertical-align:top; font-weight:normal“ id=”ASCII“>}/th><td headers=”matches posix ASCII“>All ASCII:[\x00-\x7F]</td></tr tr><><th style=”vertical-align:top; font-weight:normal“ id=”Alpha“>\p{Alpha}</th><td headers=”matches posix Alpha“>An alphabetic character:[\p{IsAlphabetic]}</td/tr tr><><th style=”vertical-align:top; font-weight:normal“ id=”Digit“>\p{IsDigit}</th><td>< headers=”matches posix Digit”<\p{ASCII>十進位數: \p{gc=Decimal_Number}</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“Alnum”>\p{Alnum}/th><td headers=“matches posix Alnum”>An alphanumeric character:[\p{Alpha\p{Digit}]}<</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“Punct”>\p{Punct}</th><td headers=“matches posix Punct”>Punctuation: \p{IsPunctuation}</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”Graph“>}/th><td headers=”matches posix Graph“>A visible character: [^p{space\p{gc=Control}\p{gc=Surrogate}\p{gc=Unassigned}]}</td></tr tr>><<th style=”vertical-align:top; font-weight:normal“ id=”Print“\p{Print>}</th><td headers=”matches posix Print“>A printable character: [\p{Graph\p{Blank}&&&[^\p{Cntrl}]]}</td></tr tr><<><\p{Graphth style=“vertical-align:top;font-weight:normal“ id=”Blank“>}/th><td headers=”matches posix Blank“>A space or a tab: [\p{gc=Space_Separator\N{CHARACTER TABULATION}]}</td></tr tr><><th style=”vertical-align:top; font-weight:normal“ id=”Cntrl“>\p{Cntrl}</th><td headers=”matches posix Cntrl“>A control character: \p{gc=Control}</td></tr tr<>th><style=”vertical-align:top; font-weight:normal“ id=”XDigit<\p{Blank“>}/th><td headers=”matches posix XDigit“>A十六進位數位: [\p{gc=Decimal_Number\p{IsHex_Digit}]}</td></tr tr><><th style=”vertical-align:top; font-weight:normal“ id=”Space“\p{Space>}</th<>td headers=”matches posix Space“>A空格符: \p{IsWhite_Space}</td></tr tr>><<th style=”vertical-align:top; font-weight:normal“ id=”PosixCompatible“><\p{XDigitPOSIX 相容表達式</th<>td 標頭=“符合 posix PosixCompatible”>請參閱 Unicode 檔</td></tr>
<tr><th colspan=“2” style=“padding-top:20px” id=“java”>java.lang.Character classes (simple java character type)</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“javaLowerCase”\p{javaLowerCase>}</th<>td headers=“matches java javaLowerCase”>相當於 java.lang.Character.isLowerCase()</td></tr tr<>><th style=“vertical-align:top; font-weight:normal” id=“javaUpperCase”>\p{javaUpperCase}</th><td headers=“matches java javaUpperCase”>相當於 java.lang.Character.isUpperCase()</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”javaWhitespace“>}/th<>td headers=”matches java javaWhitespace“>相當於 java.lang.Character.isWhitespace()</td></tr tr tr><><th style=”vertical-align:top; font-weight:normal“ id=”javaMirrored“\p{javaMirrored>}</th><td headers=”matches java javaMirrored“>相當於 java.lang.Character.isMirrored()</td></tr<\p{javaWhitespace>
<tr><th colspan=“2” style=“padding-top:20px” id=“unicode”>Classes for Unicode scripts, blocks, categories and binary properties</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“IsLatin”>\p{IsLatin}</th><td headers=“matches unicode IsLatin”>A Latin script character (script)</td></tr th><><style=“vertical-align:top; font-weight:normal” id=“InGreek”\p{InGreek>}</th><td headers=“matches unicode InGreek”>A character ingresp;block (block)</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“Lu”>\p{Lu}</th><td headers=“matches unicode Lu”>An uppercase letter (category)</td></tr tr><<>th style=“vertical-align:top; font-weight:normal” id=“IsAlphabetic”>\p{IsAlphabetic}</th><td headers=“matches unicode IsAlphabetic”>An alphabetic character (binary property)</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”Sc“>}/th><td headers=”matches unicode Sc“>A currency symbol</td></tr tr><><th style=”vertical-align:top; font-weight:normal“ id=”not_InGreek“>\P{InGreek}</th<>td headers=”matches unicode not_InGreek“>除了希臘區塊 (negation)</td></tr tr><><th style=”vertical-align:top; font-weight:normal“ id=”not_uppercase“[\p{L><\p{Sc&&[^\p{Lu}]}</th<>td headers=“matches unicode not_uppercase”>任何字母,但大寫字母(減法)</td></tr>
<tr><th colspan=“2” style=“padding-top:20px” id=“bounds”>Boundary matchers</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“begin_line”^></th<>td headers=“matches bounds begin_line”>line</td></tr tr<>th><style=“vertical-align:top; font-weight:normal” id=“end_line”>$</th><td headers=“matches bounds end_line”>line</td></tr tr<>th><style=“vertical-align:top; font-weight:normal” id=“word_boundary”>\b</th><td headers=“matches bounds word_boundary”>A word boundary</td></tr tr><<>th style=“vertical-align:top; font-weight:normal” id=“non_word_boundary”\B<>/th><td headers=“matches bounds non_word_boundary”>A non-word boundary</td/tr tr><><th style=“vertical-align:top; font-weight:normal” id=“begin_input”<>\A/th<>td>< headers=“matches boundsbegin_input“>input/td/tr tr><th><style=”vertical-align:top; font-weight:normal“ id=”end_prev_match“>\G</th td headers=”matchs bounds end_prev_match“>上一個 match</td><></tr tr><th><style=”vertical-align:top; font-weight:normal“ id=”end_input_except_term“<>\Z/th><<>td headers=”matchs bounds end_input_except_term“><輸入的結尾,但針對最終終止符,if any</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“end_input”>\z</th><td headers=“matches bounds end_input”>input</td></tr 的結尾>
<tr><th colspan=“2” style=“padding-top:20px” id=“linebreak”>Linebreak matcher</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“any_unicode_linebreak”\R<>/th><td headers=“matches linebreak any_unicode_linebreak”>Any Unicode linebreak sequence, is equivalent to \u000D\u000A|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029] </td></tr>
<tr><th colspan=“2” style=“padding-top:20px” id=“grapheme”>Unicode Extended Grapheme matcher</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“grapheme_any”>\X</th<>td headers=“matches grapheme grapheme_any”>Any Unicode extended grapheme cluster</td></tr>
<tr><th colspan=“2” style=“padding-top:20px” id=“greedy”Greedy“>Greedy 數量值</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“greedy_once_or_not”>X?</th<>td headers=“matches greedy greedy_once_or_not”>X, once or not at all</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“greedy_zero_or_more”>X/th<>td headers=“matches greedy greedy_zero_or_more”>X*<, zero or more times</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“greedy_one_or_more”>X+</th><td headers=“matchedy greedy_one_or_more”>X, one 或多次</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“greedy_exactly”>X{n}</th><td headers=“matches greedy greedy_exactly”>X, exactly n times</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“greedy_at_least”>X n,}</th td headers=“matchedy greedy_at_least”>X{, 至少 n times</td></tr tr<><>th><style=“vertical-align:top; font-weight:normal” id=“greedy_at_least_up_to”>X{n,m}</th><td headers=“符合貪婪greedy_at_least_up_to”>X,至少 n 但不超過 m 次</td></tr>
<tr><th colspan=“2” style=“padding-top:20px” id=“reluc”>不情願數量值</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“reluc_once_or_not”>X??</th<>td headers=“matches reluc reluc_once_or_not”>X, once or not at all</td/tr tr>><<th style=“vertical-align:top; font-weight:normal” id=“reluc_zero_or_more”>X/th><td>< headers=“matches reluc reluc_zero_or_more”>X<*?, zero or more times</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“reluc_one_or_more”>X+?</th td headers=“matches reluc reluc_one_or_more”>X, one 或多次</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“reluc_exactly”>X{n}?</th><><td headers=“matches reluc reluc_exactly”>X, exactly n times</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“reluc_at_least”>X{n,}?</th><td headers=“matches reluc reluc_at_least”>X, 至少 n times</td></tr tr><th><style=“vertical-align:top; font-weight:normal” id=“reluc_at_least_up_to”>X{n,m<}?/th><td headers=“matches reluc reluc_at_least_up_to”>X,至少 n 但不超過 m times</td></tr>
<tr><th colspan=“2” style=“padding-top:20px” id=“poss”>Possessive 數量值</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“poss_once_or_not”>X<?+/th<>td headers=“matches poss poss_once_or_not”>X, once or not at all</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“poss_zero_or_more”>X/th<>td headers=“matches poss poss_zero_or_more”>X<*+, zero 或 more times</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”poss_one_or_more“>X++</th<>td headers=”matches poss poss_one_or_more“>X, one 或多次/td></tr tr<><>th style=”vertical-align:top; font-weight:normal“ id=”poss_exactly>“X{n}+</th<>td headers=”matches poss poss_exactly“>X, exactly n times<</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”poss_at_least“>X{n<,}+/th<>td headers=”matches poss poss_at_least“>X, 至少 n times</td/tr th<><>style=”vertical-align:top; font-weight:normal“ id=”poss_at_least_up_to“>X{n,m}+</th><td>< headers=”matches poss poss_at_least_up_to“>X, 至少n 但不超過 m times</td></tr>
<tr><th colspan=“2” style=“padding-top:20px” id=“logical”>Logical operators</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“concat”>XY</th td headers=“matches logical concat”>X followed by Y</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“alternate”X|Y</th<>><td headers=“matches logical alternate>”>Either X or Y</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”group“>(X<)/th><td headers=”matches logical group“>X, as a capturing group</td></tr>
<tr><th colspan=“2” style=“padding-top:20px” id=“backref”>Back references</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“back_nth”>\n</th<>td headers=“matches backref back_nth”>無論 n<sup th</sup>> 擷取群組相符</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“back_named”>\k<
<tr><th colspan=“2” style=“padding-top:20px” id=“quote”>Quote</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“quote_follow”>\</th td headers=“matches quote quote_follow”>Nothing, but quotes the following character/td/tr tr><><th style=“vertical-align:top; font-weight:normal” id=“quote_begin<\Q>”/th><<>td>< headers=“matches quote quote_begin”>Nothing, but quotes all characters< until \E</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”quote_end“>\E</th><td headers=”matches quote quote_end“Nothing,>但結束以 /td></tr<> 開頭\Q<的引號-- Metachars: !$()*+.?<>[\]^{|}-->
<tr><th colspan=“2” style=“padding-top:20px” id=“special”>Special constructs (named-capturing and non-capturing)</th></tr>
<tr><th style=“vertical-align:top; font-weight:normal” id=“named_group”(?<<a href="#groupname">name</a>>>X)</th<>td headers=“matches special named_group”>X, as a named-capturing group. 僅適用於 API 26 或更新版本。</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“non_capture_group”(?:>X)</th td headers=“matches special non_capture_group”>X, as a non-capturing group</td/tr tr<>th style=“vertical-align:top; font-weight:normal” id=“flags”(?idmsux-idmsux) ></th><> sU on - off</td><></tr><tr><><th style=“vertical-align:top; font-weight:normal” id=“non_capture_group_flags“>(?idmsuxU-idmsuxU:X) </th>td headers=“matches special non_capture_group_flags”>X, 作為具有指定旗標 du</a > U on - off</td></tr tr<>><th style=“vertical-align:top; font-weight:normal” id=“pos_lookahead”><c>(?=</c><i>X/i><c>)</c></th><td headers=“符合特殊pos_lookahead”><i X<</i>>,透過零寬度正向 lookahead</td/><<tr tr><><th style=“vertical-align:top; font-weight:normal” id=“neg_lookahead”><c>(?!</c><i X<>/i><c>)</c></th><td headers=“matches special neg_lookahead”><i>X</i>, via zero-width negative lookahead</td/tr th><<>style=“vertical-align:top; font-weight:normal” id=“pos_lookbehind”c>(?<=</><c i>X</i><c>)</c></th<>td>< headers=“matches special pos_lookbehind><”><i X</i>>, via零寬度正外觀behind</td></tr tr>><<th style=“vertical-align:top; font-weight:normal” id=“neg_lookbehind”><c>(?<!</c><i>X</i><c>)</c></th><td headers=“符合特殊neg_lookbehind”><i>X</i>,透過零寬度負外觀behind</td></tr tr><><th style=“vertical-align:top; font-weight:normal” id=“indep_non_capture_group”><c>(?></c><i>X</i><c>)</c></th><td headers=“符合特殊indep_non_capture_group”><i>X</i>,作為獨立的非擷取群組</td></tr>
</tbody></table>
<人力資源>
<h2>“bs”>反斜杠、逸出和引用</h2>
反斜杠字元 ('\') 用來導入如上表所定義的逸出建構,以及將否則解譯為未逸出建構的引號字元。 因此,表達式 \\ 會比對單一反斜杠,並 \{ 符合左大括弧。
在任何不表示逸出建構的字母字元之前,使用反斜杠是錯誤的;這些會保留給正則表達式語言的未來延伸模組。 不論該字元是否為未逸出建構的一部分,反斜杠都可以在非字母字元之前使用。
以引用 Java 語言規格</引用>>為 <Unicode 逸出專案來解譯 Java 原始程式碼中字串常值內的反斜杠(section {
已在1.4中新增。
的 java.util.regex.PatternJava 檔。
此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。
欄位
| CanonEq |
已淘汰.
Android 不支援此旗標。 |
| CaseInsensitive |
已淘汰.
啟用不區分大小寫的比對。 |
| Comments |
已淘汰.
允許模式中的空格元和批注。 |
| Dotall |
已淘汰.
啟用 dotall 模式。 |
| Literal |
已淘汰.
啟用模式的常值剖析。 |
| Multiline |
已淘汰.
啟用多行模式。 |
| UnicodeCase |
已淘汰.
啟用 Unicode 感知大小寫折疊。 |
| UnicodeCharacterClass |
已淘汰.
Android 不支援此旗標,而且一律會使用 Unicode 字元類別。 |
| UnixLines |
已淘汰.
啟用 Unix 行模式。 |
屬性
| Class |
傳回這個 |
| Handle |
基礎Android實例的句柄。 (繼承來源 Object) |
| JniIdentityHashCode |
正則表達式的編譯表示。 (繼承來源 Object) |
| JniPeerMembers |
正則表達式的編譯表示。 |
| PeerReference |
正則表達式的編譯表示。 (繼承來源 Object) |
| ThresholdClass |
此 API 支援適用於 Android 的 Mono 基礎結構,並不適合直接從您的程式代碼使用。 (繼承來源 Object) |
| ThresholdType |
此 API 支援適用於 Android 的 Mono 基礎結構,並不適合直接從您的程式代碼使用。 (繼承來源 Object) |
方法
| AsMatchPredicate() |
建立述詞,以測試此模式是否符合指定的輸入字串。 |
| AsPredicate() |
建立述詞,以測試指定的輸入字串中是否找到此模式。 |
| Clone() |
建立並傳回這個 對象的複本。 (繼承來源 Object) |
| Compile(String) |
將指定的正則表達式編譯成模式。 |
| Compile(String, RegexOptions) |
將指定的正則表示式編譯成具有指定旗標的模式。 |
| Dispose() |
正則表達式的編譯表示。 (繼承來源 Object) |
| Dispose(Boolean) |
正則表達式的編譯表示。 (繼承來源 Object) |
| Equals(Object) |
指出其他物件是否「等於」這個物件。 (繼承來源 Object) |
| Flags() |
傳回此模式的比對旗標。 |
| GetHashCode() |
傳回此物件的雜湊碼值。 (繼承來源 Object) |
| InvokePattern() |
傳回編譯此模式的正則表達式。 |
| JavaFinalize() |
當垃圾收集決定不再參考物件時,垃圾收集行程在 物件上呼叫。 (繼承來源 Object) |
| Matcher(ICharSequence) |
建立比對器,以符合此模式的指定輸入。 |
| Matcher(String) |
建立比對器,以符合此模式的指定輸入。 |
| Matches(String, ICharSequence) |
編譯指定的正則表示式,並嘗試比對指定的輸入。 |
| Matches(String, String) |
編譯指定的正則表示式,並嘗試比對指定的輸入。 |
| Notify() |
喚醒正在等候此物件監視器的單一線程。 (繼承來源 Object) |
| NotifyAll() |
喚醒正在等候此物件監視器的所有線程。 (繼承來源 Object) |
| Quote(String) |
傳回指定 |
| SetHandle(IntPtr, JniHandleOwnership) |
設定 Handle 屬性。 (繼承來源 Object) |
| Split(ICharSequence) |
將指定的輸入序列分割為此模式的相符專案。 |
| Split(ICharSequence, Int32) |
將指定的輸入序列分割為此模式的相符專案。 |
| Split(String) |
將指定的輸入序列分割為此模式的相符專案。 |
| Split(String, Int32) |
將指定的輸入序列分割為此模式的相符專案。 |
| ToArray<T>() |
正則表達式的編譯表示。 (繼承來源 Object) |
| ToString() |
傳回物件的字串表示。 (繼承來源 Object) |
| UnregisterFromRuntime() |
正則表達式的編譯表示。 (繼承來源 Object) |
| Wait() |
讓目前線程等候直到喚醒為止,通常是藉由em <notified/em>或<em>interrupted</em> 來喚醒它。<> (繼承來源 Object) |
| Wait(Int64) |
讓目前的線程等到喚醒為止,通常是因為 <em>notified</em> 或 <em>interrupted</em>,或直到經過一定數量的實時為止。 (繼承來源 Object) |
| Wait(Int64, Int32) |
讓目前的線程等到喚醒為止,通常是因為 <em>notified</em> 或 <em>interrupted</em>,或直到經過一定數量的實時為止。 (繼承來源 Object) |
明確介面實作
| IJavaPeerable.Disposed() |
正則表達式的編譯表示。 (繼承來源 Object) |
| IJavaPeerable.DisposeUnlessReferenced() |
正則表達式的編譯表示。 (繼承來源 Object) |
| IJavaPeerable.Finalized() |
正則表達式的編譯表示。 (繼承來源 Object) |
| IJavaPeerable.JniManagedPeerState |
正則表達式的編譯表示。 (繼承來源 Object) |
| IJavaPeerable.SetJniIdentityHashCode(Int32) |
正則表達式的編譯表示。 (繼承來源 Object) |
| IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
正則表達式的編譯表示。 (繼承來源 Object) |
| IJavaPeerable.SetPeerReference(JniObjectReference) |
正則表達式的編譯表示。 (繼承來源 Object) |
擴充方法
| JavaCast<TResult>(IJavaObject) |
執行 Android 執行時間檢查的類型轉換。 |
| JavaCast<TResult>(IJavaObject) |
正則表達式的編譯表示。 |
| GetJniTypeName(IJavaPeerable) |
正則表達式的編譯表示。 |