Skip to content

Instantly share code, notes, and snippets.

@martinhj
Last active November 18, 2020 08:53
Show Gist options
  • Save martinhj/4f4ceea4a139bdce11c4b28201cc14c1 to your computer and use it in GitHub Desktop.
Save martinhj/4f4ceea4a139bdce11c4b28201cc14c1 to your computer and use it in GitHub Desktop.
Regex greed quantifiers
Greedy quantifier Lazy quantifier Description
* *? Star Quantifier: 0 or more
+ +? Plus Quantifier: 1 or more
? ?? Optional Quantifier: 0 or 1
{n} {n}? Quantifier: exactly n
{n,} {n,}? Quantifier: n or more
{n,m} {n,m}? Quantifier: between n and m

https://stackoverflow.com/questions/2301285#34806154

+-------------------+-----------------+------------------------------+
| Greedy quantifier | Lazy quantifier | Description |
+-------------------+-----------------+------------------------------+
| * | *? | Star Quantifier: 0 or more |
| + | +? | Plus Quantifier: 1 or more |
| ? | ?? | Optional Quantifier: 0 or 1 |
| {n} | {n}? | Quantifier: exactly n |
| {n,} | {n,}? | Quantifier: n or more |
| {n,m} | {n,m}? | Quantifier: between n and m |
+-------------------+-----------------+------------------------------+
https://stackoverflow.com/questions/2301285#34806154
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment