<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html
  SYSTEM "about:legacy-compat">
<html xmlns:mml = "http://www.w3.org/1998/Math/MathML" lang = "zh-tw"><head><meta charset = "UTF-8"/><meta name = "copyright" content = "(C) Copyright 2020"/><meta name = "DC.rights.owner" content = "(C) Copyright 2020"/><meta name = "DC.type" content = "reference"/><meta name = "abstract" content = "規則運算式可在「濾器」工場與「搜尋」窗格中使用，也可用於 DisableMatchingProperties 進階設定。本主題列出規則運算式語法及縮寫。"/><meta name = "description" content = "規則運算式可在「濾器」工場與「搜尋」窗格中使用，也可用於 DisableMatchingProperties 進階設定。本主題列出規則運算式語法及縮寫。"/><meta name = "DC.format" content = "HTML5"/><meta name = "DC.identifier" content = "cps-r-ReferenceInformation-RegularExpressionSyntax"/><meta name = "DC.language" content = "zh-tw"/><link rel = "stylesheet" type = "text/css" href = "../DSDocUI_XML34.css"/><title>參考資訊：規則運算式語法</title>
<script type = "text/javascript" src = "../DSDocUI_Highlight34.js">
  	/* */
  	</script></head><body onLoad = "highlightSearchTerms();" id = "cps-r-ReferenceInformation-RegularExpressionSyntax">
<a name = "hj-top"> </a><table class = "table1" id = "table11"><tr><td><table class = "DocHeader"><tr><td class = "DocHeader1" colspan = "2"><h1>參考資訊：規則運算式語法</h1></td></tr><tr><td class = "DocHeader4" colspan = "2"/></tr><tr><td class = "DocHeader3" colspan = "2"><table class = "DocThemeIntro" id = "table12"><tr><td class = "Intro1Only"><p class = "header"><p class = "abstract">
    <span class = "shortdesc">規則運算式可在「濾器」工場與「搜尋」窗格中使用，也可用於 <span class = "ph uicontrol">DisableMatchingProperties</span> 進階設定。本主題列出規則運算式語法及縮寫。</span>

  </p>
<p>此頁面內容包括： </p><ul><li><a href = "#r-RegularExpressionSyntax" id = "toc_rg" title = "此表格列出您可作為規則運算式使用的中繼字元。">規則運算式語法</a></li><li><a href = "#r-Abbreviations" id = "toc_rg" title = "此表列出支援的縮寫，例如 \d，而非 [0-9]。">縮寫</a></li></ul>
</p></td></tr></table></td></tr></table>
  

  
  <article class = "topic reference nested1" aria-labelledby = "ariaid-title2" id = "r-RegularExpressionSyntax">
    <h2 class = "title topictitle2">規則運算式語法</h2>

    
    <div class = "body refbody"><p class = "abstract">
      <span class = "shortdesc">此表格列出您可作為規則運算式使用的中繼字元。</span>

    </p>

      <table class = "table frame-none"><caption/><colgroup><col style = "width:50%"/><col style = "width:50%"/></colgroup><thead class = "thead">
            <tr class = "row">
              <th class = "entry" id = "r-RegularExpressionSyntax__entry__1">中繼字元</th>
              <th class = "entry" id = "r-RegularExpressionSyntax__entry__2">意義</th>
            </tr>
          </thead><tbody class = "tbody">
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">。</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">比對任何單一字元。</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">[ ]</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">指示字元類別。比對方括號內的任何字元 (例如，<kbd class = "ph userinput userinput">[abc]</kbd> 會比對「a」、「b」及「c」)。</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">^</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">如果此中繼字元出現在字元類別的開頭，它可否定字元類別。否定的字元類別會比對方括號內以外的任何字元 (例如，<kbd class = "ph userinput userinput">[^abc]</kbd> 會比對除了「a」、「b」與「c」以外的所有字元)。<p>如果 ^ 位於規則運算式的開頭，它會比對輸入的開頭 (例如，<kbd class = "ph userinput userinput">^[abc]</kbd> 將只比對以「a」、「b」或「c」為開頭的輸入)。</p></td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">-</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">在字元類別中，表示字元範圍 (例如，<kbd class = "ph userinput userinput">[0-9]</kbd> 會比對從「0」到「9」的任何數字)。</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">?</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">表示前置的運算式是選用的：它會比對一次或完全都不比對 (例如，<kbd class = "ph userinput userinput">[0-9][0-9]?</kbd> 會比對「2」與「12」)。</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">+</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">表示前置運算式會比對一次或多次 (例如，<kbd class = "ph userinput userinput">[0-9]+</kbd> 會比對「1」、「13」、「456」等)。</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">*</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">指示前置運算式比對零或多次。</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">??、+?、*?</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">?、+ 與 * 的非貪婪版本。這些項目會盡可能少比對，不像貪婪版本會盡可能多比對 (例如，假設輸入為「&lt;abc&gt;&lt;def&gt;」，<kbd class = "ph userinput userinput">&lt;.*?&gt;</kbd> 會比對「&lt;abc&gt;」，而 <kbd class = "ph userinput userinput">&lt;.*&gt;</kbd> 會比對「&lt;abc&gt;&lt;def&gt;」)。</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">( )</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">分組運算符。例如：<kbd class = "ph userinput userinput">(\d+,)*\d+</kbd> 會比對以逗號分隔的數字清單 (例如「1」或「1,23,456」)。</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">{ }</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">指示比對群組。</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">\</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">
                <p>逸出字元：照字面意義解譯下一個字元 (例如，<kbd class = "ph userinput userinput">[0-9]+</kbd> 會比對一個或多個數字，但 <kbd class = "ph userinput userinput">[0-9]\+</kbd> 會比對後面有加號字元的一個數字)。這也可用於縮寫 (例如，適用於任何英數字元的 <kbd class = "ph userinput userinput">\a</kbd>；請參閱下表)。</p>
                <p>如果 \ 後跟數字 n，它會比對第 n 個比對群組 (從 0 開始)。例如：<kbd class = "ph userinput userinput">&lt;{.*?}&gt;.*&lt;/\0&gt;</kbd> 符合「&lt;head&gt;Contents&lt;/head&gt;」。</p>
              </td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">$</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">在規則運算式的結尾，此字元會比對輸入的結尾 (例如，<kbd class = "ph userinput userinput">[0-9]$</kbd> 會比對輸入結尾的數字)。</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">|</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">交替運算符：可分隔兩個運算式，其中一個完全相符 (例如，<kbd class = "ph userinput userinput">T|the</kbd> 會比對「The」或「the」)。</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__1">!</td>
              <td class = "entry" headers = "r-RegularExpressionSyntax__entry__2">否定運算符：接在 ! 之後的運算式不會比對輸入 (例如，<kbd class = "ph userinput userinput">a!b</kbd> 會比對後面沒有「b」的「a」)。</td>
            </tr>
          </tbody></table>
    </div>

  </article>
  <article class = "topic reference nested1" aria-labelledby = "ariaid-title3" id = "r-Abbreviations">
    <p><map name = "FPMap1"><area href = "#hj-top" title = "回到頁首" shape = "rect" coords = "416, 0, 435, 10"/></map><span class = "itemsprite"/></p><h2 class = "title topictitle2">縮寫</h2>

    
    <div class = "body refbody"><p class = "abstract">
      <span class = "shortdesc">此表列出支援的縮寫，例如 <kbd class = "ph userinput userinput">\d</kbd>，而非 <kbd class = "ph userinput userinput">[0-9]</kbd>。</span>

    </p>

      <table class = "table frame-none"><caption/><colgroup><col style = "width:50%"/><col style = "width:50%"/></colgroup><thead class = "thead">
            <tr class = "row">
              <th class = "entry" id = "r-Abbreviations__entry__1">縮寫</th>
              <th class = "entry" id = "r-Abbreviations__entry__2">比對</th>
            </tr>
          </thead><tbody class = "tbody">
            <tr class = "row">
              <td class = "entry" headers = "r-Abbreviations__entry__1">\a</td>
              <td class = "entry" headers = "r-Abbreviations__entry__2">任何英數字元：([a-zA-Z0-9])</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-Abbreviations__entry__1">\b</td>
              <td class = "entry" headers = "r-Abbreviations__entry__2">空白字元 (空格)：([ \\t])</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-Abbreviations__entry__1">\c</td>
              <td class = "entry" headers = "r-Abbreviations__entry__2">任何字母字元：([a-zA-Z])</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-Abbreviations__entry__1">\d</td>
              <td class = "entry" headers = "r-Abbreviations__entry__2">任何十進位數字：([0-9])</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-Abbreviations__entry__1">\h</td>
              <td class = "entry" headers = "r-Abbreviations__entry__2">任何十六進位數字：([0-9a-fA-F])</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-Abbreviations__entry__1">\n</td>
              <td class = "entry" headers = "r-Abbreviations__entry__2">新行：(\r|(\r?\n))</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-Abbreviations__entry__1">\q</td>
              <td class = "entry" headers = "r-Abbreviations__entry__2">引用的字串：(\"[^\"]*\")|(\'[^\']*\')</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-Abbreviations__entry__1">\w</td>
              <td class = "entry" headers = "r-Abbreviations__entry__2">簡單的字：([a-zA-Z]+)</td>
            </tr>
            <tr class = "row">
              <td class = "entry" headers = "r-Abbreviations__entry__1">\z</td>
              <td class = "entry" headers = "r-Abbreviations__entry__2">整數：([0-9]+)</td>
            </tr>
          </tbody></table>
    </div>

  </article>
</td></tr></table><script type = "text/javascript" src = "../DSDocUI_Bottom34.js">/* */</script></body>
</html>
