| Feature | Syntax | Description | Example | JGsoft | Python | JavaScript | VBScript | XRegExp | .NET | Java | ICU | RE2 | Perl | PCRE | PCRE2 | PHP | Delphi | R | Ruby | std::regex | Boost | Tcl | POSIX | GNU | 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 | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA extended egrep awk | ECMA extended egrep awk | YES | extended | extended | YES | YES | YES |
| Greedy quantifier | \? | Makes the preceding item optional. Greedy, so the optional item is included in the match if possible. | abc\? matches abc or ab | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | basic | no | no | no |
| Lazy quantifier | ?? | Makes the preceding item optional. Lazy, so the optional item is excluded in the match if possible. | abc?? matches ab or abc | YES | YES | YES | YES | YES | YES | YES | YES | default | YES | YES | YES | YES | YES | YES | YES | ECMA | ECMA | YES | no | no | YES | no | YES |
| 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 | YES | 3.11 | no | no | no | no | YES | YES | no | YES | YES | YES | YES | YES | YES | 1.9 | no | ECMA 1.42 | no | no | no | no | no | no |
| 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 | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES |
| 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 | YES | YES | YES | YES | YES | YES | YES | YES | default | YES | YES | YES | YES | YES | YES | YES | ECMA | ECMA | YES | no | no | YES | no | YES |
| 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 | YES | 3.11 | no | no | no | no | YES | YES | no | YES | YES | YES | YES | YES | YES | 1.9 | no | ECMA 1.42 | no | no | no | no | no | no |
| 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 | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA extended egrep awk | ECMA extended egrep awk | YES | extended | extended | YES | YES | YES |
| 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 | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | basic | no | no | no |
| 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 | YES | YES | YES | YES | YES | YES | YES | YES | default | YES | YES | YES | YES | YES | YES | YES | ECMA | ECMA | YES | no | no | YES | no | YES |
| 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 | YES | 3.11 | no | no | no | no | YES | YES | no | YES | YES | YES | YES | YES | YES | 1.9 | no | ECMA 1.42 | no | no | no | no | no | no |
| Fixed quantifier | {n} where n is an integer >= 1 | Repeats the previous item exactly n times. | a{3} matches aaa | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA extended egrep awk | ECMA extended egrep awk | YES | extended | extended | YES | YES | YES |
| 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 | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA extended egrep awk | ECMA extended egrep awk | YES | extended | extended | YES | YES | YES |
| 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 | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | ECMA extended egrep awk | ECMA extended egrep awk | YES | extended | extended | YES | YES | YES |
| 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 | V2 | YES | with /u error | no | no | no | error | error | no | 5.36 5.22 error | no | 10.43 | no | no | 4.4.0 | 1.9 1.8 error | ECMA extended egrep awk error | ECMA 1.38–1.57 extended 1.38–1.89 egrep 1.38–1.89 awk 1.38–1.89 error | no | no | extended | no | error | error |
| Fixed quantifier | \{n\} where n is an integer >= 1 | Repeats the previous item exactly n times. | a\{3\} matches aaa | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | basic grep | basic grep | no | basic | basic | no | no | no |
| 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 | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | basic grep | basic grep | no | basic | basic | no | no | no |
| 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 | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | basic grep | basic grep | no | basic | basic | no | no | no |
| 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 | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | no | basic | no | no | no |
| 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 | YES | YES | YES | YES | YES | YES | YES | YES | default | YES | YES | YES | YES | YES | YES | YES | ECMA | ECMA | YES | no | no | YES | no | YES |
| 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 | YES | YES | YES | YES | YES | YES | YES | YES | default | YES | YES | YES | YES | YES | YES | YES | ECMA | ECMA | YES | no | no | YES | no | YES |
| 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 | V2 | YES | with /u error | no | no | no | error | error | no | 5.36 5.22 error | no | 10.43 | no | no | 4.4.0 | 1.9 1.8 error | ECMA extended egrep awk error | ECMA 1.38–1.57 extended 1.38–1.89 egrep 1.38–1.89 awk 1.38–1.89 error | no | no | no | no | error | error |
| 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 | YES | 3.11 | no | no | no | no | YES | YES | no | YES | YES | YES | YES | YES | YES | no | no | ECMA 1.42 | no | no | no | no | no | no |
| 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 | YES | 3.11 | no | no | no | no | YES | YES | no | YES | YES | YES | YES | YES | YES | no | no | ECMA 1.42 | no | no | no | no | no | no |
| Possessive quantifier | {,m}+ where m >= 1 | Repeats the previous item between zero 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{,4}+a matches aaaaa but not aaaa | YES | 3.11 | no | no | no | no | YES | YES | no | YES | YES | YES | YES | YES | YES | no | no | ECMA 1.42 | no | no | no | no | no | no |
| Bounded quantifier | {n} and {n,m} with n or m = 1000 | Bounded quantifiers allow at least 1,000 repetitions as the upper bound. | a{1000} matches 1,000 letters. | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | YES | error | error | YES | YES | YES | YES |
| Bounded quantifier | {n} and {n,m} with n or m = 32766 | Bounded quantifiers allow at least 32,766 (215−2) repetitions as the upper bound. | a{32766} matches 32,766 letters. | YES | YES | YES | YES | YES | YES | YES | YES | error | YES | YES | YES | YES | YES | YES | YES | YES | YES | error | error | error | YES | YES | YES |
| Bounded quantifier | {n} and {n,m} with n or m = 65534 | Bounded quantifiers allow at least 65,534 (216−2) repetitions as the upper bound. | a{65534} matches 65,534 letters. | YES | YES | YES | YES | YES | YES | YES | YES | error | 5.30 5.14 error | YES | YES | YES | YES | YES | 1.9 1.8 error | YES | YES | error | error | error | YES | YES | YES |
| Bounded quantifier | {n} and {n,m} with n or m = 65535 | Bounded quantifiers allow at least 65,535 (216−1) repetitions as the upper bound. | a{65535} matches 65,535 letters. | YES | YES | YES | YES | YES | YES | YES | YES | error | 5.38 5.14 error | YES | YES | YES | YES | YES | 1.9 1.8 error | YES | YES | error | error | error | YES | YES | YES |
| Bounded quantifier | {n} and {n,m} with n or m = 65536 | Bounded quantifiers allow at least 65,536 (216) repetitions as the upper bound. | a{65536} matches 65,536 letters. | YES | 2.7 2.5 error 2.4 fail | YES | YES | YES | YES | YES | YES | error | 5.38 5.14 error | error | error | error | error | error | 1.9 1.8 error | VC’12 | YES | error | error | error | fail | YES | YES |
| Bounded quantifier | {n} and {n,m} with n or m = 100000 | Bounded quantifiers allow at least 100,000 repetitions as the upper bound. | a{100000} matches 100,000 letters. | YES | 2.7 2.5 error 2.4 fail | YES | YES | YES | YES | YES | YES | error | 5.38 5.14 error | error | error | error | error | error | 1.9 1.8 error | VC’12 | YES | error | error | error | fail | YES | YES |
| Bounded quantifier | {n} and {n,m} with n or m = 16777215 | Bounded quantifiers allow at least 16,777,215 (1024-1) repetitions as the upper bound. | a{16777215} matches 16,777,215 letters. | YES | 2.7 2.5 error 2.4 fail | YES | YES | YES | YES | YES | YES | error | 5.38 5.14 error | error | error | error | error | error | error | VC’12 | YES | error | error | error | fail | YES | YES |
| Bounded quantifier | {n} and {n,m} with n or m = 999999999 | Bounded quantifiers allow at least 999,999,999 repetitions as the upper bound. | a{999999999} matches 999,999,999 letters. | YES | 2.7 2.5 error 2.4 fail | YES | YES | YES | YES | YES | error | error | 5.38 5.14 error | error | error | error | error | error | error | VC’12 | YES | error | error | error | fail | YES | YES |
| Bounded quantifier | {n} and {n,m} with n or m = 2147483646 | Bounded quantifiers allow at least 2,147,483,646 (231−2) repetitions as the upper bound. | a{2147483646} matches 2,147,483,646 letters. | no | 2.7 2.5 error 2.4 fail | YES | YES | YES | YES | YES | error | error | 5.38 5.14 error | error | error | error | error | error | error | VC’12 | YES | error | error | error | fail | YES | YES |
| Bounded quantifier | {n} and {n,m} with n or m = 2147483647 | Bounded quantifiers allow at least 2,147,483,647 (231−1) repetitions as the upper bound. | a{2147483647} matches 2,147,483,647 letters. | no | 2.7 2.5 error 2.4 fail | YES | YES | YES | YES | YES | error | error | error | error | error | error | error | error | error | VC’12 | YES | error | error | error | fail | YES | YES |
| Feature | Syntax | Description | Example | JGsoft | Python | JavaScript | VBScript | XRegExp | .NET | Java | ICU | RE2 | Perl | PCRE | PCRE2 | PHP | Delphi | R | Ruby | std::regex | Boost | Tcl | POSIX | GNU | Oracle | XML | XPath |
| Quick Start | Tutorial | Search & Replace | Tools & Languages | Examples | Reference |
| Introduction | Table of Contents | Quick Reference | Characters | Basic Features | Character Classes | Shorthands | Anchors | Word Boundaries | Quantifiers | Capturing Groups & Backreferences | Named Groups & Backreferences | Special Groups | Unicode Characters and Properties | Unicode Versions | Unicode Categories | Unicode Scripts | Unicode Blocks | Unicode Binary Properties | Unicode Property Sets | Unicode Boundaries | Mode Modifiers | Recursion & Balancing Groups | Backtracking Control Verbs |
| Characters | Matched Text & Backreferences | Case Conversion | Context | Conditionals |
Page URL: https://www.regular-expressions.info/refrepeat.html
Page last updated: 12 September 2025
Site last updated: 29 October 2025
Copyright © 2003-2025 Jan Goyvaerts. All rights reserved.