<?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"><head><meta charset = "UTF-8"/><meta name = "copyright" content = "(C) 版权 2020"/><meta name = "DC.rights.owner" content = "(C) 版权 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"/><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">表示前面的表达式为可选：匹配 1 次还是完全不匹配（例如，<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">表示前面的表达式匹配 1 次或多次（例如，<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">表示前面的表达式匹配 0 次或多次。</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;内容&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>
