正则表达式参考:量词正则表达式参考:量词正则表达式参考:量词正则表达式参考:量词
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2024年3月5日
类别
  • 正则表达式
标签
正则表达式参考:量词
  • 简
  • 繁
  • En
关于正则表达式 » 正则表达式参考 » 正则表达式参考:量词

正则表达式参考
简介
目录
快速参考
字符
基本功能
字符类别
速记
锚点
字词边界
量词
Unicode
捕获组和反向引用
命名组和反向引用
特殊组
模式修改器
递归和平衡组
替换参考
字符
配对文本和反向引用
内容和大小写转换
条件
更多内容
简介
正则表达式快速入门
正则表达式教程
替换字符串教程
应用程序和语言
正则表达式范例
正则表达式参考
替换字符串参考

正则表达式参考:量词

功能语法说明范例.NET Java Perl PCRE PCRE2 PHP Delphi R JavaScript VBScript XRegExp Python Ruby std::regex Boost Tcl ARE POSIX BRE POSIX ERE GNU BRE GNU ERE Oracle XML XPath
贪婪量词 ?(问号) 使前一个项目为选用。贪婪,因此如果可能的话,选用项目会包含在配对中。 abc? 配对 abc 或 ab 是是是是是是是是是是是是是ECMA
延伸
egrep
awk
ECMA
延伸
egrep
awk
是否是否是是是是
贪婪量词 \? 使前一个项目为选用。贪婪,因此如果可能的话,选用项目会包含在配对中。 abc\? 配对 abc 或 ab 否否否否否否否否否否否否否否否否否否是否否否否
延迟量词 ?? 使前一个项目为选用。延迟,因此如果可能的话,选用项目会排除在配对之外。 abc?? 配对 ab 或 abc 是是是是是是是是是是是是是ECMAECMA是否否否否10gR2否是
占有量词 ?+ 使前一个项目为选用。占有,因此如果可以配对选用项目,即使正则表达式的其余部分失败,量词也不会放弃其配对。 abc?+c 配对 abcc,但不配对 abc 否是5.10是是是是是否否否否1.9否ECMA
1.42–1.83
否否否否否否否否
贪婪量词 *(星号) 重复前一个项目零次或多次。贪婪,因此在尝试与前一个项目匹配较少的排列之前,将匹配尽可能多的项目,直到完全不匹配前一个项目为止。 ".*" 在 abc "def" "ghi" jkl 中匹配 "def" "ghi" 是是是是是是是是是是是是是是是是是是是是是是是
延迟量词 *? 重复前一个项目零次或多次。惰性,因此引擎会先尝试跳过前一个项目,然后再尝试与前一个项目匹配越来越多的排列。 ".*?" 在 abc "def" "ghi" jkl 中匹配 "def" 和 "ghi" 是是是是是是是是是是是是是ECMAECMA是否否否否10gR2否是
占有量词 *+ 重复前一个项目零次或多次。独占,因此将匹配尽可能多的项目,而不会尝试与匹配较少的任何排列,即使 regex 的其余部分失败。 ".*+" 永远无法匹配任何内容 否是5.10是是是是是否否否否1.9否ECMA
1.42–1.83
否否否否否否否否
贪婪量词 +(加号) 重复前一个项目一次或多次。贪婪,因此在尝试与前一个项目匹配较少的排列之前,将匹配尽可能多的项目,直到前一个项目仅匹配一次为止。 ".+" 在 abc "def" "ghi" jkl 中匹配 "def" "ghi" 是是是是是是是是是是是是是ECMA
延伸
egrep
awk
ECMA
延伸
egrep
awk
是否是否是是是是
贪婪量词 \+ 重复前一个项目一次或多次。贪婪,因此在尝试与前一个项目匹配较少的排列之前,将匹配尽可能多的项目,直到前一个项目仅匹配一次为止。 ".\+" 在 abc "def" "ghi" jkl 中匹配 "def" "ghi" 否否否否否否否否否否否否否否否否否否是否否否否
延迟量词 +? 重复前一个项目一次或多次。惰性,因此引擎会先匹配前一个项目仅一次,然后再尝试与前一个项目匹配越来越多的排列。 ".+?" 在 abc "def" "ghi" jkl 中匹配 "def" 和 "ghi" 是是是是是是是是是是是是是ECMAECMA是否否否否10gR2否是
占有量词 ++ 重复前一个项目一次或多次。独占,因此将匹配尽可能多的项目,而不会尝试与匹配较少的任何排列,即使 regex 的其余部分失败。 ".++" 永远无法匹配任何内容 否是5.10是是是是是否否否否1.9否ECMA
1.42–1.83
否否否否否否否否
固定量词 {n} 其中 n 是整数 >= 1 重复前一个项目 n 次。 a{3} 符合 aaa 是是是是是是是是是是是是是ECMA
延伸
egrep
awk
ECMA
延伸
egrep
awk
是否是否是是是是
贪婪量词 {n,m} 其中 n >= 0 且 m >= n 重复前一个项目 n 到 m 次。贪婪,因此会先尝试重复 m 次,再减少重复次数为 n 次。 a{2,4} 符合 aaaa、aaa 或 aa 是是是是是是是是是是是是是ECMA
延伸
egrep
awk
ECMA
延伸
egrep
awk
是否是否是是是是
贪婪量词 {n,} 其中 n >= 0 重复前一个项目至少 n 次。贪婪,因此会尽可能符合项目,直到前一个项目只符合 n 次为止,才会尝试符合较少次数的排列组合。 a{2,} 在 aaaaa 中符合 aaaaa 是是是是是是是是是是是是是ECMA
延伸
egrep
awk
ECMA
延伸
egrep
awk
是否是否是是是是
贪婪量词 {,m} 其中 m >= 1 重复前一个项目 0 到 m 次。贪婪,因此会先尝试重复 m 次,再减少重复次数为 0 次。 a{,4} 符合 aaaa、aaa、aa、a 或空字符串 否否否否否否否否否否否是1.9否否否否否否是否否否
固定量词 \{n\} 其中 n 是整数 >= 1 重复前一个项目 n 次。 a\{3\} 符合 aaa 否否否否否否否否否否否否否基本
grep
基本
grep
否是否是否否否否
贪婪量词 \{n,m\} 其中 n >= 0 且 m >= n 重复前一个项目 n 到 m 次。贪婪,因此会先尝试重复 m 次,再减少重复次数为 n 次。 a\{2,4\} 符合 aaaa、aaa 或 aa 否否否否否否否否否否否否否基本
grep
基本
grep
否是否是否否否否
贪婪量词 \{n,\} 其中 n >= 0 重复前一个项目至少 n 次。贪婪,因此会尽可能符合项目,直到前一个项目只符合 n 次为止,才会尝试符合较少次数的排列组合。 a\{2,\} 在 aaaaa 中符合 aaaaa 否否否否否否否否否否否否否基本
grep
基本
grep
否是否是否否否否
贪婪量词 \{,m\} 其中 m >= 1 重复前一个项目 0 到 m 次。贪婪,因此会先尝试重复 m 次,再减少重复次数为 0 次。 a\{,4\} 符合 aaaa、aaa、aa、a 或空字符串 否否否否否否否否否否否否否否否否否否是否否否否
延迟量词 {n,m}? 其中 n >= 0 且 m >= n 重复前一个项目 n 到 m 次。非贪婪,因此会先尝试重复 n 次,再增加重复次数为 m 次。 a{2,4}? 符合 aa、aaa 或 aaaa 是是是是是是是是是是是是是ECMAECMA是否否否否10gR2否是
延迟量词 {n,}? 其中 n >= 0 重复前一个项目 n 次或更多次。惰性,因此引擎会先将前一个项目符合 n 次,再尝试使用前一个项目的符合次数不断增加的排列组合。 a{2,}? 在 aaaaa 中符合 aa 是是是是是是是是是是是是是ECMAECMA是否否否否10gR2否是
延迟量词 {,m}? 其中 m >= 1 重复前一个项目 0 到 m 次。惰性,因此会先尝试重复 0 次,再将重复次数增加到 m 次。 a{,4}? 符合空字符串、a、aa、aaa 或 aaaa 否否否否否否否否否否否是1.9否否否否否否否否否否
占有量词 {n,m}+ 其中 n >= 0 且 m >= n 重复前一个项目 n 到 m 次。独占,因此会符合尽可能多的项目,直到 m,而不会尝试任何符合次数较少的排列组合,即使正则表达式的其余部分失败。 a{2,4}+a 符合 aaaaa,但不符合 aaaa 否是5.10是是是是是否否否否否否ECMA
1.42–1.83
否否否否否否否否
占有量词 {n,}+ 其中 n >= 0 重复前一个项目 n 次或更多次。独占,因此会符合尽可能多的项目,而不会尝试任何符合次数较少的排列组合,即使正则表达式的其余部分失败。 a{2,}+a 永远不会符合任何项目 否是5.10是是是是是否否否否否否ECMA
1.42–1.83
否否否否否否否否
功能语法说明范例.NET Java Perl PCRE PCRE2 PHP Delphi R JavaScript VBScript XRegExp Python Ruby std::regex Boost Tcl ARE POSIX BRE POSIX ERE GNU BRE GNU ERE Oracle XML XPath
正規表示式參考:量詞
  • 简
  • 繁
  • En
關於正規表示式 » 正規表示式參考 » 正規表示式參考:量詞

正規表示式參考
簡介
目錄
快速參考
字元
基本功能
字元類別
速記
錨點
字詞邊界
量詞
Unicode
擷取群組和反向參照
命名群組和反向參照
特殊群組
模式修改器
遞迴和平衡群組
替換參考
字元
配對文字和反向參照
內容和大小寫轉換
條件
本網站的更多資訊
簡介
正規表示式快速入門
正規表示式教學
替換字串教學
應用程式和語言
正規表示式範例
正規表示式參考
替換字串參考

正規表示式參考:量詞

功能語法說明範例.NET Java Perl PCRE PCRE2 PHP Delphi R JavaScript VBScript XRegExp Python Ruby std::regex Boost Tcl ARE POSIX BRE POSIX ERE GNU BRE GNU ERE Oracle XML XPath
貪婪量詞 ?(問號) 使前一個項目為選用。貪婪,因此如果可能的話,選用項目會包含在配對中。 abc? 配對 abc 或 ab 是是是是是是是是是是是是是ECMA
延伸
egrep
awk
ECMA
延伸
egrep
awk
是否是否是是是是
貪婪量詞 \? 使前一個項目為選用。貪婪,因此如果可能的話,選用項目會包含在配對中。 abc\? 配對 abc 或 ab 否否否否否否否否否否否否否否否否否否是否否否否
延遲量詞 ?? 使前一個項目為選用。延遲,因此如果可能的話,選用項目會排除在配對之外。 abc?? 配對 ab 或 abc 是是是是是是是是是是是是是ECMAECMA是否否否否10gR2否是
佔有量詞 ?+ 使前一個項目為選用。佔有,因此如果可以配對選用項目,即使正規表示式的其餘部分失敗,量詞也不會放棄其配對。 abc?+c 配對 abcc,但不配對 abc 否是5.10是是是是是否否否否1.9否ECMA
1.42–1.83
否否否否否否否否
貪婪量詞 *(星號) 重複前一個項目零次或多次。貪婪,因此在嘗試與前一個項目匹配較少的排列之前,將匹配盡可能多的項目,直到完全不匹配前一個項目為止。 ".*" 在 abc "def" "ghi" jkl 中匹配 "def" "ghi" 是是是是是是是是是是是是是是是是是是是是是是是
延遲量詞 *? 重複前一個項目零次或多次。惰性,因此引擎會先嘗試跳過前一個項目,然後再嘗試與前一個項目匹配越來越多的排列。 ".*?" 在 abc "def" "ghi" jkl 中匹配 "def" 和 "ghi" 是是是是是是是是是是是是是ECMAECMA是否否否否10gR2否是
佔有量詞 *+ 重複前一個項目零次或多次。獨佔,因此將匹配盡可能多的項目,而不會嘗試與匹配較少的任何排列,即使 regex 的其餘部分失敗。 ".*+" 永遠無法匹配任何內容 否是5.10是是是是是否否否否1.9否ECMA
1.42–1.83
否否否否否否否否
貪婪量詞 +(加號) 重複前一個項目一次或多次。貪婪,因此在嘗試與前一個項目匹配較少的排列之前,將匹配盡可能多的項目,直到前一個項目僅匹配一次為止。 ".+" 在 abc "def" "ghi" jkl 中匹配 "def" "ghi" 是是是是是是是是是是是是是ECMA
延伸
egrep
awk
ECMA
延伸
egrep
awk
是否是否是是是是
貪婪量詞 \+ 重複前一個項目一次或多次。貪婪,因此在嘗試與前一個項目匹配較少的排列之前,將匹配盡可能多的項目,直到前一個項目僅匹配一次為止。 ".\+" 在 abc "def" "ghi" jkl 中匹配 "def" "ghi" 否否否否否否否否否否否否否否否否否否是否否否否
延遲量詞 +? 重複前一個項目一次或多次。惰性,因此引擎會先匹配前一個項目僅一次,然後再嘗試與前一個項目匹配越來越多的排列。 ".+?" 在 abc "def" "ghi" jkl 中匹配 "def" 和 "ghi" 是是是是是是是是是是是是是ECMAECMA是否否否否10gR2否是
佔有量詞 ++ 重複前一個項目一次或多次。獨佔,因此將匹配盡可能多的項目,而不會嘗試與匹配較少的任何排列,即使 regex 的其餘部分失敗。 ".++" 永遠無法匹配任何內容 否是5.10是是是是是否否否否1.9否ECMA
1.42–1.83
否否否否否否否否
固定量詞 {n} 其中 n 是整數 >= 1 重複前一個項目 n 次。 a{3} 符合 aaa 是是是是是是是是是是是是是ECMA
延伸
egrep
awk
ECMA
延伸
egrep
awk
是否是否是是是是
貪婪量詞 {n,m} 其中 n >= 0 且 m >= n 重複前一個項目 n 到 m 次。貪婪,因此會先嘗試重複 m 次,再減少重複次數為 n 次。 a{2,4} 符合 aaaa、aaa 或 aa 是是是是是是是是是是是是是ECMA
延伸
egrep
awk
ECMA
延伸
egrep
awk
是否是否是是是是
貪婪量詞 {n,} 其中 n >= 0 重複前一個項目至少 n 次。貪婪,因此會盡可能符合項目,直到前一個項目只符合 n 次為止,才會嘗試符合較少次數的排列組合。 a{2,} 在 aaaaa 中符合 aaaaa 是是是是是是是是是是是是是ECMA
延伸
egrep
awk
ECMA
延伸
egrep
awk
是否是否是是是是
貪婪量詞 {,m} 其中 m >= 1 重複前一個項目 0 到 m 次。貪婪,因此會先嘗試重複 m 次,再減少重複次數為 0 次。 a{,4} 符合 aaaa、aaa、aa、a 或空字串 否否否否否否否否否否否是1.9否否否否否否是否否否
固定量詞 \{n\} 其中 n 是整數 >= 1 重複前一個項目 n 次。 a\{3\} 符合 aaa 否否否否否否否否否否否否否基本
grep
基本
grep
否是否是否否否否
貪婪量詞 \{n,m\} 其中 n >= 0 且 m >= n 重複前一個項目 n 到 m 次。貪婪,因此會先嘗試重複 m 次,再減少重複次數為 n 次。 a\{2,4\} 符合 aaaa、aaa 或 aa 否否否否否否否否否否否否否基本
grep
基本
grep
否是否是否否否否
貪婪量詞 \{n,\} 其中 n >= 0 重複前一個項目至少 n 次。貪婪,因此會盡可能符合項目,直到前一個項目只符合 n 次為止,才會嘗試符合較少次數的排列組合。 a\{2,\} 在 aaaaa 中符合 aaaaa 否否否否否否否否否否否否否基本
grep
基本
grep
否是否是否否否否
貪婪量詞 \{,m\} 其中 m >= 1 重複前一個項目 0 到 m 次。貪婪,因此會先嘗試重複 m 次,再減少重複次數為 0 次。 a\{,4\} 符合 aaaa、aaa、aa、a 或空字串 否否否否否否否否否否否否否否否否否否是否否否否
延遲量詞 {n,m}? 其中 n >= 0 且 m >= n 重複前一個項目 n 到 m 次。非貪婪,因此會先嘗試重複 n 次,再增加重複次數為 m 次。 a{2,4}? 符合 aa、aaa 或 aaaa 是是是是是是是是是是是是是ECMAECMA是否否否否10gR2否是
延遲量詞 {n,}? 其中 n >= 0 重複前一個項目 n 次或更多次。惰性,因此引擎會先將前一個項目符合 n 次,再嘗試使用前一個項目的符合次數不斷增加的排列組合。 a{2,}? 在 aaaaa 中符合 aa 是是是是是是是是是是是是是ECMAECMA是否否否否10gR2否是
延遲量詞 {,m}? 其中 m >= 1 重複前一個項目 0 到 m 次。惰性,因此會先嘗試重複 0 次,再將重複次數增加到 m 次。 a{,4}? 符合空字串、a、aa、aaa 或 aaaa 否否否否否否否否否否否是1.9否否否否否否否否否否
佔有量詞 {n,m}+ 其中 n >= 0 且 m >= n 重複前一個項目 n 到 m 次。獨佔,因此會符合儘可能多的項目,直到 m,而不會嘗試任何符合次數較少的排列組合,即使正規表示式的其餘部分失敗。 a{2,4}+a 符合 aaaaa,但不符合 aaaa 否是5.10是是是是是否否否否否否ECMA
1.42–1.83
否否否否否否否否
佔有量詞 {n,}+ 其中 n >= 0 重複前一個項目 n 次或更多次。獨佔,因此會符合儘可能多的項目,而不會嘗試任何符合次數較少的排列組合,即使正規表示式的其餘部分失敗。 a{2,}+a 永遠不會符合任何項目 否是5.10是是是是是否否否否否否ECMA
1.42–1.83
否否否否否否否否
功能語法說明範例.NET Java Perl PCRE PCRE2 PHP Delphi R JavaScript VBScript XRegExp Python Ruby std::regex Boost Tcl ARE POSIX BRE POSIX ERE GNU BRE GNU ERE Oracle XML XPath
Regular Expression Reference: Quantifiers
  • 简
  • 繁
  • En
About Regular Expressions » Regular Expressions Reference » Regular Expression Reference: Quantifiers

Regex Reference
Introduction
Table of Contents
Quick Reference
Characters
Basic Features
Character Classes
Shorthands
Anchors
Word Boundaries
Quantifiers
Unicode
Capturing Groups & Backreferences
Named Groups & Backreferences
Special Groups
Mode Modifiers
Recursion & Balancing Groups
Replacement Reference
Characters
Matched Text & Backreferences
Context & Case Conversion
Conditionals
More on This Site
Introduction
Regular Expressions Quick Start
Regular Expressions Tutorial
Replacement Strings Tutorial
Applications and Languages
Regular Expressions Examples
Regular Expressions Reference
Replacement Strings Reference

Regular Expression Reference: Quantifiers

FeatureSyntaxDescriptionExample.NET Java Perl PCRE PCRE2 PHP Delphi R JavaScript VBScript XRegExp Python Ruby std::regex Boost Tcl ARE POSIX BRE POSIX ERE GNU BRE GNU ERE Oracle XML XPath
Greedy quantifier ? (question mark) Makes the preceding item optional. Greedy, so the optional item is included in the match if possible. abc? matches abc or ab YESYESYESYESYESYESYESYESYESYESYESYESYESECMA
extended
egrep
awk
ECMA
extended
egrep
awk
YESnoYESnoYESYESYESYES
Greedy quantifier \? Makes the preceding item optional. Greedy, so the optional item is included in the match if possible. abc\? matches abc or ab nonononononononononononononononononoYESnononono
Lazy quantifier ?? Makes the preceding item optional. Lazy, so the optional item is excluded in the match if possible. abc?? matches ab or abc YESYESYESYESYESYESYESYESYESYESYESYESYESECMAECMAYESnononono10gR2noYES
Possessive quantifier ?+ Makes the preceding item optional. Possessive, so if the optional item can be matched, then the quantifier won’t give up its match even if the remainder of the regex fails. abc?+c matches abcc but not abc noYES5.10YESYESYESYESYESnononono1.9noECMA
1.42–1.83
nononononononono
Greedy quantifier * (star) Repeats the previous item zero or more times. Greedy, so as many items as possible will be matched before trying permutations with less matches of the preceding item, up to the point where the preceding item is not matched at all. ".*" matches "def" "ghi" in abc "def" "ghi" jkl YESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYESYES
Lazy quantifier *? Repeats the previous item zero or more times. Lazy, so the engine first attempts to skip the previous item, before trying permutations with ever increasing matches of the preceding item. ".*?" matches "def" and "ghi" in abc "def" "ghi" jkl YESYESYESYESYESYESYESYESYESYESYESYESYESECMAECMAYESnononono10gR2noYES
Possessive quantifier *+ Repeats the previous item zero or more times. Possessive, so as many items as possible will be matched, without trying any permutations with less matches even if the remainder of the regex fails. ".*+" can never match anything noYES5.10YESYESYESYESYESnononono1.9noECMA
1.42–1.83
nononononononono
Greedy quantifier + (plus) Repeats the previous item once or more. Greedy, so as many items as possible will be matched before trying permutations with less matches of the preceding item, up to the point where the preceding item is matched only once. ".+" matches "def" "ghi" in abc "def" "ghi" jkl YESYESYESYESYESYESYESYESYESYESYESYESYESECMA
extended
egrep
awk
ECMA
extended
egrep
awk
YESnoYESnoYESYESYESYES
Greedy quantifier \+ Repeats the previous item once or more. Greedy, so as many items as possible will be matched before trying permutations with less matches of the preceding item, up to the point where the preceding item is matched only once. ".\+" matches "def" "ghi" in abc "def" "ghi" jkl nonononononononononononononononononoYESnononono
Lazy quantifier +? Repeats the previous item once or more. Lazy, so the engine first matches the previous item only once, before trying permutations with ever increasing matches of the preceding item. ".+?" matches "def" and "ghi" in abc "def" "ghi" jkl YESYESYESYESYESYESYESYESYESYESYESYESYESECMAECMAYESnononono10gR2noYES
Possessive quantifier ++ Repeats the previous item once or more. Possessive, so as many items as possible will be matched, without trying any permutations with less matches even if the remainder of the regex fails. ".++" can never match anything noYES5.10YESYESYESYESYESnononono1.9noECMA
1.42–1.83
nononononononono
Fixed quantifier {n} where n is an integer >= 1 Repeats the previous item exactly n times. a{3} matches aaa YESYESYESYESYESYESYESYESYESYESYESYESYESECMA
extended
egrep
awk
ECMA
extended
egrep
awk
YESnoYESnoYESYESYESYES
Greedy quantifier {n,m} where n >= 0 and m >= n Repeats the previous item between n and m times. Greedy, so repeating m times is tried before reducing the repetition to n times. a{2,4} matches aaaa, aaa or aa YESYESYESYESYESYESYESYESYESYESYESYESYESECMA
extended
egrep
awk
ECMA
extended
egrep
awk
YESnoYESnoYESYESYESYES
Greedy quantifier {n,} where n >= 0 Repeats the previous item at least n times. Greedy, so as many items as possible will be matched before trying permutations with less matches of the preceding item, up to the point where the preceding item is matched only n times. a{2,} matches aaaaa in aaaaa YESYESYESYESYESYESYESYESYESYESYESYESYESECMA
extended
egrep
awk
ECMA
extended
egrep
awk
YESnoYESnoYESYESYESYES
Greedy quantifier {,m} where m >= 1 Repeats the previous item between zero and m times. Greedy, so repeating m times is tried before reducing the repetition to zero times. a{,4} matches aaaa, aaa, aa, a, or the empty string nononononononononononoYES1.9nonononononoYESnonono
Fixed quantifier \{n\} where n is an integer >= 1 Repeats the previous item exactly n times. a\{3\} matches aaa nononononononononononononobasic
grep
basic
grep
noYESnoYESnononono
Greedy quantifier \{n,m\} where n >= 0 and m >= n Repeats the previous item between n and m times. Greedy, so repeating m times is tried before reducing the repetition to n times. a\{2,4\} matches aaaa, aaa or aa nononononononononononononobasic
grep
basic
grep
noYESnoYESnononono
Greedy quantifier \{n,\} where n >= 0 Repeats the previous item at least n times. Greedy, so as many items as possible will be matched before trying permutations with less matches of the preceding item, up to the point where the preceding item is matched only n times. a\{2,\} matches aaaaa in aaaaa nononononononononononononobasic
grep
basic
grep
noYESnoYESnononono
Greedy quantifier \{,m\} where m >= 1 Repeats the previous item between zero and m times. Greedy, so repeating m times is tried before reducing the repetition to zero times. a\{,4\} matches aaaa, aaa, aa, a, or the empty string nonononononononononononononononononoYESnononono
Lazy quantifier {n,m}? where n >= 0 and m >= n Repeats the previous item between n and m times. Lazy, so repeating n times is tried before increasing the repetition to m times. a{2,4}? matches aa, aaa or aaaa YESYESYESYESYESYESYESYESYESYESYESYESYESECMAECMAYESnononono10gR2noYES
Lazy quantifier {n,}? where n >= 0 Repeats the previous item n or more times. Lazy, so the engine first matches the previous item n times, before trying permutations with ever increasing matches of the preceding item. a{2,}? matches aa in aaaaa YESYESYESYESYESYESYESYESYESYESYESYESYESECMAECMAYESnononono10gR2noYES
Lazy quantifier {,m}? where m >= 1 Repeats the previous item between zero and m times. Lazy, so repeating zero times is tried before increasing the repetition to m times. a{,4}? matches the empty string, a, aa, aaa or aaaa nononononononononononoYES1.9nononononononononono
Possessive quantifier {n,m}+ where n >= 0 and m >= n Repeats the previous item between n and m times. Possessive, so as many items as possible up to m will be matched, without trying any permutations with less matches even if the remainder of the regex fails. a{2,4}+a matches aaaaa but not aaaa noYES5.10YESYESYESYESYESnonononononoECMA
1.42–1.83
nononononononono
Possessive quantifier {n,}+ where n >= 0 Repeats the previous item n or more times. Possessive, so as many items as possible will be matched, without trying any permutations with less matches even if the remainder of the regex fails. a{2,}+a never matches anything noYES5.10YESYESYESYESYESnonononononoECMA
1.42–1.83
nononononononono
FeatureSyntaxDescriptionExample.NET Java Perl PCRE PCRE2 PHP Delphi R JavaScript VBScript XRegExp Python Ruby std::regex Boost Tcl ARE POSIX BRE POSIX ERE GNU BRE GNU ERE Oracle XML XPath
©2015-2025 艾丽卡 support@alaica.com