語言

Pattern 類別

定義

一個正則表達式的編譯表示。

[Android.Runtime.Register("java/util/regex/Pattern", DoNotGenerateAcw=true)]
public sealed class Pattern : Java.Lang.Object, IDisposable, 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 字元序列與正則表達式匹配。 所有參與配對的狀態都集中在配對者身上,因此許多配對者可能共享相同的模式。

典型的召喚序列如下

<引用>

Pattern p = Pattern.{@link #compile compile}("a*b");
            Matcher m = p.{@link #matcher matcher}("aaaaab");
            boolean b = m.{@link Matcher#matches matches}();

</區塊引用>

此類別定義的方法 #matches matches ,作為當正則表達式只使用一次時的便利。 此方法編譯一個表達式,並在單一調用中將輸入序列與之匹配。 陳述式

<引用>

boolean b = Pattern.matches("a*b", "aaaaab");

</區塊引用>

等價於上述三個陳述,但對於重複匹配,效率較低,因為它不允許重複使用已編譯的模式。

此類別的實例是不可變的,且可被多個並行執行緒安全使用。 該類別的實例 Matcher 並不安全用於此類用途。

<h2>“sum”> 正則表達式結構<摘要/h2>

<table class=“borderless”caption style=“display:none”Regular expression constructs, and what they match</>caption><thead style=“text-align:left”<>tr><th id=“construct”>Construct</th><th id=“matches”>匹配</th></tr></thead><tbody style=“text-align:left”><>

<tr><th colspan=“2” style=“padding-top:20px” id=“characters”>Characters</th></tr>

trth style=“vertical-align:top; font-weight: normal” id=“x”x/thtd headers=“match characters x”字元 x/td/trtr thstyle=“vertical-align:top; font-weight: normal” id=“backslash”/thtd headers=“matches characters backslash”The backslash character/td/trtrth style=“vertical-align:top; font-weight: normal” id=“octal_n”n/thtd headers=“match characters octal_n” 八進位值為 n 的字元 (0&nbsp;&nbsp;n&nbsp;&nbsp;7)/td/trtr thstyle=“vertical-align:top; font-weight: normal” id=“octal_nn”nn/thtd headers=“match characters octal_nn” 八進位值為 nn (0&nbsp;&nbsp;n&nbsp;&nbsp;7)/td/trtr thstyle=“vertical-align:top; font-weight: normal” id=“octal_nnn”mnn/thtd headers=“match characters octal_nnn” 八進位值為 mnn (0&nbsp;&nbsp;m&nbsp;&nbsp;3, 0&nbsp;&nbsp;n&nbsp;&nbsp;7)/td/trtr thstyle=“vertical-align:top; font-weight: normal” id=“hex_hh”hh/thtd headers=“match characters hex_hh” 十六進位值為 hh/td/trtrth style=“vertical-align:top; font-weight: normal” id=“”hex_hhhh“hhhh/thtd headers=”match characters hex_hhhh“ 字元十六進位&nbsp;價值&nbsp;哈——/td/trtrth style=“vertical-align:top;font-weight: normal” id=“hex_h_h”{h...h}/thtd headers=“匹配字元hex_h_h” 十六進位值為 h... 的字元。h (&nbsp;<=&nbsp;h...h&nbsp;<=&nbsp;)/td/trtrth style=“vertical-align:top; font-weight: normal” id=“unicode_name”name/thtd headers=“match characters unicode_name” 具有 Unicode 字元名稱 'name'/td/trtrth style=“vertical-align:top; font-weight:normal” id=“tab”/thtd headers=“matches characters tab”該標籤character ()/td/trtr thstyle=“vertical-align:top; font-weight:normal” id=“newline”/thtd headers=“匹配字元換行” 換行(換行)字元()/td/trtrth style=“vertical-align:top; font-weight:normal” id=“return”/thtd headers=“match characters return”回車字元 ()/td/trtr thstyle=“vertical-align:top; font-weight:normal” id=“form_feed”/thtd headers=“match characters form_feed” 表單換送字元 ()/td/trtrth style=“vertical-align:top; font-weight:normal” id=“bell”/thtd headers=“match characters bell”alert (bell) 字元(bell)/td/trtr th style=“vertical-align:top; font-weight:normal” id=“escape”/thtd headers=“匹配字元逃脫” 跳脫字元 ()/td/trtrth style=“vertical-align:top; font-weight:normal” id=“ctrl_x”x/thtd headers=“匹配字元 ctrl_x” 對應於 x/td/tr 的控制字元

<tr><th colspan=“2” style=“padding-top:20px” id=“classes”>字元類別/<th></tr>

<tr><th style=“vertical-align:top; font-weight:normal” id=“simple”>[abc]</th><td headers=“matches classes simple”a>, b, or c (simple class)</td></tr<>tr><th style=“vertical-align:top; font-weight:normal” id=“negation”[^abc]></th<>td headers=“matches classes negation”>除 a、 b或 c (negation)</td></tr><tr>< 以外任何字元皆可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><th><style=”vertical-align:top; font-weight:normal“ id=”union“<[a-d[m-p]]>/th<>td headers=”Matches classes union“>a through d, or m through p: [a-dm-p] (union)</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”intersection“>[a-z&&[def]]</th><td headers=”matches classes intersection“>d,e或 f (intersection)</tr><th><style =”vertical-align:top; font-weight:normal“ id=”subtraction1“[a-z&&[^bc]]<>/th><td headers=”match classes subtraction1“>a through z,但不包括 b 及 c: [ad-z] (subtraction)</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”subtraction2“>[a-z&&[^m-p]]</th><td headers=”匹配類別 subtraction2“>a 透過 z,且非m透過 p: [a-lq-z](subtraction)</td></tr>

<tr><th colspan=“2” style=“padding-top:20px” id=“predef”> Preset character classes/<th></tr>

<tr><th style=“vertical-align:top; font-weight:normal” id=“any”<.>/th><td headers=“match predef any”>任意字元(可能與行終止符相符也可能不匹配)</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“digit”>\d</th><td headers=“match predef digit”>A digit: \p{IsDigit}</td></tr<>tr><th style=“vertical-align:top; font-weight:normal” id=“non_digit”>/th><td headers=“matches predef non_digit”A> non-figure:<[^\d] /td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“horiz_white”<>\h/th><td headers=“matches predef horiz_white”>水平空白字元:<[ \t\xA0&#92;u1680&#92;u180e&#92;u2000-&#92;u200a&#92;u202f&#92;u205f&#92;u3000]/td></tr<>tr><th style=“vertical-align:top; font-weight:normal” id=“non_horiz_white”>\H</th><td headers=”\D<匹配 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“>空白字元:\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”> 垂直空白字元:[\n\x0B\f\r\x85&#92;u2028&#92;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”> 非垂直空白字元<字元:[^\v]</td></tr<>tr th><style=“vertical-align:top; font-weight:normal” id=“word”\w></th<>td headers=“matches predef word”>字元:[\p{alpha\p{gc=Mark}\p{digit}\p{gc=Connector_Punctuation}\p{Join_Control}]}</td></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 感知)</b></th></tr>

<tr><th style=“vertical-align:top; font-weight:normal” id=“Lower”\p{Lower>}</th><td headers=“matches posix Lower”>小寫字母:\p{IsLowercase}</td></tr<>tr><th style=“vertical-align:top; font-weight:normal” id=“Upper”>\p{Upper}</th><td headers=“matches posix Upper”>大寫字母:\p{IsUppercase}</td></tr><tr><th style=“vertical-align:top; font-weight:normal“ id=”ASCII“>}/th><td headers=”matches posix ASCII“> 所有 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=“match posix Alnum”>一個字母數字字符:[\p{Alpha\p{Digit}]}</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“Punct”>\p{Punct}</th><td headers=“match posix Punct”標>點符號: \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“>空格或製表符:[\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“>控制字元:\p{gc=Control}</td></tr<>tr><th style=”vertical-align:top; font-weight:normal“ id=”XDigit<\p{Blank“>}/th<>td headers=”match posix XDigit“>一個十六進位數字:[\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“>空白字元:\p{IsWhite_Space}</td></tr><tr><th style=”vertical-align:top; font-weight:normal“ id=”PosixCompatible“POSIX-Compatible><\p{XDigitexpression</th<>td headers=“matches posix PosixCompatible”,>請參閱 Unicode 文件/<td></tr>

<tr><th colspan=“2” style=“padding-top:20px” id=“java”java.lang.Character> classes(簡單 Java 字元類型)</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><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”>Unicode 腳本、區塊、類別及二進位屬性<類別/th></tr>

<tr><th style=“vertical-align:top; font-weight:normal” id=“IsLatin”>\p{IsLatin}</th><td headers=“matches unicode IsLatin”A Latin&>nbsp;script character (script)/td></tr<>tr><th style=“vertical-align:top; font-weight:normal” id=“InGreek”\p{InGreek>}</th><td headers=“matches unicode InGreek”> 希臘文中的一個字元 <block (block)</td></tr<>tr th><style=“vertical-align:top; font-weight:normal” id=“Lu”\p{Lu>}</th><td headers=“match unicode Lu”>An overcarce (category)</td></tr<>tr><th style=“vertical-align:top; font-weight:normal” id=“IsAlphabetic”\p{IsAlphabetic>}</th<>td headers=“matches unicode IsAlphabetic”> 一個字母字符(二進位屬性)</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”Sc“>}/th><td headers=”matches unicode Sc“>貨幣符號</td></tr<>tr><th style=”vertical-align:top; font-weight:normal“ id=”not_InGreek“\P{InGreek>}</th<>td headers=”matches unicode not_InGreek“>希臘文區塊中除一個字元外的任何字元(否定)</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”> 除大寫字母(減法)<><外,任意字母>

<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=“match bounds begin_line”>行首</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“end_line”>$</th><td headers=“match bounds end_line”行>尾</td></tr<>tr><th style=“vertical-align:top; font-weight:normal” id=“word_boundary”>/th<>td headers=“match 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=“match bounds non_word_boundary”> 非字詞邊界</td></tr<>tr><th style=“vertical-align:top; font-weight:normal” id=“begin_input”>\A</th><td headers=“matches bounds \b<begin_input“>輸入/td></tr><tr th><style=”vertical-align:top; font-weight:normal“ id=”end_prev_match“>\G</th><td headers=”match 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=”match 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=“match bounds end_input”> 輸入</td></tr 的結尾>

<tr><th colspan=“2” style=“padding-top:20px” id=“linebreak”>換行匹配器</th></tr>

<tr><th style=“vertical-align:top; font-weight:normal” id=“any_unicode_linebreak”\R<>/th<>td headers=“matches linechange any_unicode_linebreak”> 任何 Unicode 換行序列,都等同於 &#92;u000D&#92;u000A|[&#92;u000A&#92;u000B&#92;u000C&#92;u000D&#92;u0085&#92;u2028&#92;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”> 任意 Unicode 擴展 grapheme cluster</td></tr>

<tr><th colspan=“2” style=“padding-top:20px” id=“greedy”>貪婪量詞/<th></tr>

<tr><th style=“vertical-align:top; font-weight:normal” id=“greedy_once_or_not”X?></th<>td headers=“匹配貪婪的 greedy_once_or_not”>X, once or not< at al./td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“greedy_zero_or_more”X*<>/th<>td headers=“匹配貪婪 greedy_zero_or_more”>X,零次或多次</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“greedy_one_or_more”X+<>/th><td headers=“匹配貪婪greedy_one_or_more”>X,一次或多次</td></tr><tr><th style=“vertical-align:top; font-weight:normal” id=“greedy_exactly”>X{n}</th><td headers=“匹配貪婪greedy_exactly”>X,正好 n 次</td></tr<>tr th><style=“vertical-align:top; font-weight:normal” id=“greedy_at_least”>X{n,}</th><td headers=“匹配貪婪greedy_at_least”>X,至少 n 次</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=“match 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=“match reluc reluc_zero_or_more”>X, 0 或 more times</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”reluc_one_or_more“X+?></th><td headers=”匹配 reluc reluc_one_or_more“>X,一次或多次</td></tr<>tr><th style=”vertical-align:top; font-weight:normal“ id=”reluc_exactly“>X{ n<}?/th<>td headers=”匹配 reluc reluc_exactly“>X,正好 n 次</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”reluc_at_least“X{>n,}?</th<>td headers=”符合 reluc reluc_at_least“>X,至少 n 次</td></tr><tr><th style=”vertical-align:top; font-weight:normal“ id=”reluc_at_least_up_to“>X{n,m}?</th><td headers=”符合 reluc reluc_at_least_up_to“>X,至少 n但不能超過M倍/<TD/><TR>

<tr><th colspan=“2” style=“padding-top:20px” id=“poss”> 所有格量詞/<th></tr>

<tr><th style=“vertical-align:top; font-weight:normal” id=“poss_once_or_not”X?+></th<>td headers=“match poss poss_once_or_not”>X, once or not< at at/td></tr<>tr><th style=“vertical-align:top; font-weight:normal” id=“poss_zero_or_more”X*+></th<>td headers=“match poss poss_zero_or_more”>X, 0 次</><gt/tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”poss_one_or_more“X++></th<>td headers=”match poss poss_one_or_more“>X, one or many< times/td></tr<>tr><th style=”vertical-align:top; font-weight:normal“ id=”poss_exactly“>X{ n}+</th><td headers=”match poss poss_exactly“>X, just n times</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”poss_at_least“X{>n,}+</th<>td headers=”match poss poss_at_least“>X, 至少 n 次</td></tr<>tr><th style=”vertical-align:top; font-weight:normal“ id=”poss_at_least_up_to“>X{n,m}+</th><td headers=”match poss poss_at_least_up_to“>X,至少 n但不能超過M倍/<TD/><TR>

<tr><th colspan=“2” style=“padding-top:20px” id=“logical”>邏輯運算子/<th></tr>

<tr><th style=“vertical-align:top; font-weight:normal” id=“concat”>XY</th><td headers=“符合邏輯 concat”X> 後接 Y</td></tr><tr th><style=“vertical-align:top; font-weight:normal” id=“alternate”>X|Y</th<>td headers=“match logical alternate”>X 或Y</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”group“>(X)</th><td headers=”匹配邏輯群組“>X,作為擷取群組</td></tr>

<tr><th colspan=“2” style=“padding-top:20px” id=“backref”>Back references</th></tr>

trth style=“vertical-align:top; font-weight:normal” id=“back_nth”n/thtd headers=“matches backref back_nth”Whatever the nsupth/sup capturing group matched/td/trtrth style=“vertical-align:top; font-weight:normal” id=“back_named”k<名稱>/thtd headers=“matches backref back_named”「 命名擷取群組「name」所匹配的。 僅限於 API 26 或以上</TD></tr 等級>

<tr><th colspan=“2” style=“padding-top:20px” id=“quote”>Quoteation</th></tr>

<tr><th style=“vertical-align:top; font-weight:normal” id=“quote_follow”>\</th<>td headers=“匹配引號 quote_follow”>無,但引號為以下字元</td></tr<>tr><style =“vertical-align:top; font-weight:normal” id=“quote_begin”>\Q</th<>td headers=“匹配引號 quote_begin”>無,但引號所有字元直到 \E</td></tr tr><><th style=“vertical-align:top;font-weight:normal“ id=”quote_end“><\E/th<>td headers=”matches quote quote_end“>Nothing, but ends quotes started by \Q</td></tr><-- Metachars: !$()*+.?<>[\]^{|}-->

<tr><th colspan=“2” style=“padding-top:20px” id=“special”>特殊結構(命名擷取與非擷取)</th></tr>

<tr><th style=“vertical-align:top; font-weight:normal” id=“named_group”X)>(?&lt;<a href="#groupname">name</a>&gt;</th<>td headers=“匹配特殊 named_group”>X,作為命名擷取群組。 僅支援 API 26 或以上版本。/td/trtr thstyle = “vertical-align:top; font-weight:normal” id=“non_capture_group”X/thtd headers=“match special non_capture_group”X,作為非擷取群組/td/trtr thstyle=“vertical-align:top; font-weight:normal” id=“flags”/th sU on - off/td/trtr thstyle=“vertical-align:top; font-weight:normal” id=“non_capture_group_flags“X&nbsp;&nbsp;/thtd headers=“match special non_capture_group_flags”X,作為非捕捉群組,旗標為 du/a U on - off/td/trtr thstyle=“vertical-align:top; font-weight:normal” id=“pos_lookahead”c(?=/ciX/ic)/c/thtd headers=“match special pos_lookahead”iX/i,透過零寬度正前瞻/td/TRTRTH style=“vertical-align:top; font-weight:normal” id=“neg_lookahead”c(?!/c i X/ic)/c/thTD 標頭=“匹配特殊 neg_lookahead”iX/i,透過零寬度負前瞻/td/trtr thstyle =“vertical-align:top; font-weight:normal” id=“pos_lookbehind”c(?<=/ciX/ic)/c/thTD headers=“匹配特殊 pos_lookbehind”iX/i,透過零寬度正面 lookbehind/td/trtr thstyle = “vertical-align:top; font-weight:normal” id=“neg_lookbehind”c(?<!/c i X/ic)/c/thTD headers=“匹配特殊 neg_lookbehind”i X/i,透過零寬度負面lookbehind/td/trtr thstyle=“vertical-align:top; font-weight:normal” id=“indep_non_capture_group”c(?>/c i X/ic)/c/thtd 標頭=「匹配特殊 indep_non_capture_group」iX/i,作為獨立且非擷取的群組/td/tr

</tbody></表格>

<人資>

<H2>“BS”>反斜線、轉義與引號</h2>

反斜線字元('\')用來介紹逃逸的結構,如上表所定義,並引用原本會被解釋為未逃逸結構的字元。 因此,該表達 \\ 式與單反斜線相符,並 \{ 對應左括號。

在任何不代表逃逸結構的字母前使用反斜線是錯誤;這些資料保留給未來正則表達式語言的擴充。 無論該字元是否屬於未脫離構造,都可以在非字母字元前使用反斜線。

Java 原始碼中字串字面中的反斜線會依 <cite>的 The Java 語言規範</cite> 解釋為 Unicode 逃逸(section {

在 1.4 版本加入。

Java 文件 java.util.regex.Pattern。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

欄位

名稱 Description
CanonEq
已淘汰.

此旗標在 Android 上不支援。

CaseInsensitive
已淘汰.

啟用不區分大小寫的比對。

Comments
已淘汰.

允許在圖案中留白和註解。

Dotall
已淘汰.

啟用 dotall 模式。

Literal
已淘汰.

啟用模式的常值剖析。

Multiline
已淘汰.

啟用多行模式。

UnicodeCase
已淘汰.

啟用 Unicode 感知大小寫折疊。

UnicodeCharacterClass
已淘汰.

此旗標在 Android 上不支援,且始終使用 Unicode 字元類別。

UnixLines
已淘汰.

啟用 Unix 行模式。

屬性

名稱 Description
Class

回傳此 Object的執行時類別。

(繼承來源 Object)
Handle

底層 Android 實例的帳號。

(繼承來源 Object)
JniIdentityHashCode

取得由互通執行時指派給此 Java 對等端的身份雜湊碼。

(繼承來源 Object)
JniManagedPeerState

取得執行時最後指派的狀態旗標。

(繼承來源 JavaObject)
JniPeerMembers

取得用於存取此 Java 綁定成員的 JNI 元資料。

PeerReference

取得這個 Java 節點的 JNI 物件參考。

(繼承來源 Object)
ThresholdClass

此 API 支援 Mono for Android 基礎架構,並非直接從你的程式碼中使用。

(繼承來源 Object)
ThresholdType

此 API 支援 Mono for Android 基礎架構,並非直接從你的程式碼中使用。

(繼承來源 Object)

方法

名稱 Description
AsMatchPredicate()

建立一個謂詞來測試此模式是否與給定輸入字串相符。

AsPredicate()

建立一個謂詞,測試該模式是否存在於給定輸入字串中。

Clone()

建立並回傳此物件的副本。

(繼承來源 Object)
Compile(String, RegexOptions)

將給定的正則表達式編譯成帶有指定標誌的模式。

Compile(String)

將給定的正則表達式編譯成一個模式。

Construct(JniObjectReference, JniObjectReferenceOptions)

將此對等節點的建置委派給執行時的值管理器。

(繼承來源 JavaObject)
Dispose()

釋放該 Java 節點所持有的資源。

(繼承來源 Object)
Dispose(Boolean)

釋放該 Java 節點所持有的資源。

(繼承來源 Object)
DisposeUnlessReferenced()

請求值管理器處置此對等節點,除非其映射保留該受管理實例。

(繼承來源 JavaObject)
Equals(Object)

測試另一個受管理節點是否參考相同的 Java 物件。

(繼承來源 JavaObject)
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)

回傳指定 String的字面模式String。

SetHandle(IntPtr, JniHandleOwnership)

設定 Handle 屬性。

(繼承來源 Object)
SetPeerReference(JniObjectReference, JniObjectReferenceOptions)

在控制區塊中儲存參考值,但不建立 JNI 參考副本。

(繼承來源 JavaObject)
Split(ICharSequence, Int32)

將給定的輸入序列分割成與此模式匹配的部分。

Split(ICharSequence)

將給定的輸入序列分割成與此模式匹配的部分。

Split(String, Int32)

將給定的輸入序列分割成與此模式匹配的部分。

Split(String)

將給定的輸入序列分割成與此模式匹配的部分。

ToArray<T>()

從這個 Java 陣列包裝器建立一個受管理陣列。

(繼承來源 Object)
ToString()

回傳物件的字串表示。

(繼承來源 Object)
UnregisterFromRuntime()

將此 Java 節點從互通執行時中取消註冊。

(繼承來源 Object)
Wait()

使目前執行緒等待被喚醒,通常是透過 通知 或 中斷。

(繼承來源 Object)
Wait(Int64, Int32)

使目前執行緒等待被喚醒(通常是透過 通知 或 中斷),或等待一定的實際時間過去。

(繼承來源 Object)
Wait(Int64)

使目前執行緒等待被喚醒(通常是透過 通知 或 中斷),或等待一定的實際時間過去。

(繼承來源 Object)

明確介面實作

名稱 Description
IJavaPeerable.Disposed()

標記此節點為處置,並以disposing設定為 true的呼叫Dispose。

(繼承來源 JavaObject)
IJavaPeerable.Finalized()

標記此節點為處置,並以disposing設定為 false的呼叫Dispose。

(繼承來源 JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock

取得此對等端使用的原生控制區塊指標。

(繼承來源 JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32)

儲存執行時提供的身份雜湊碼。

(繼承來源 JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates)

取代儲存的受管理對等狀態旗標。

(繼承來源 JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference)

當引用無效時,更新對等節點並釋放已拋棄節點的控制區塊。

(繼承來源 JavaObject)
IJavaPeerable.UnregisterFromRuntime()

將此實例從執行時的 Java 物件查詢中移除。

擴充方法

名稱 Description
GetJniTypeName(IJavaPeerable)

取得實例 self類型的 JNI 名稱。

JavaAs<TResult>(IJavaPeerable)

試著強制self輸入 TResult,檢查 強制在 Java 端是否有效。

JavaCast<TResult>(IJavaObject)

執行 Android 執行時檢查型別轉換。

JavaCast<TResult>(IJavaObject)

重用相容的受管理對等端或取得請求型態的包裝器。

TryJavaCast<TResult>(IJavaPeerable, TResult)

試著強制self輸入 TResult,檢查 強制在 Java 端是否有效。

適用於