These regular expression modifiers add optional quantity data to a regular expression.
* | Zero or more matches; for example, \w* or (abc)*. Same as {0,} |
+ | One or more matches; for example, \w+ or (abc)+. Same as {1,} |
? | Zero or one matches; for example, \w? or (abc)?. Same as {0,1} |
{n} | Exactly n matches; for example, (pizza){2}. |
{n,} | At least n matches; for example, (abc){n,}. |
{n,m} | At least n, but no more than, m matches. |
*? | Lazy *. Finds the first match that consumes as few repeats as possible. |
+? | Lazy +. As few repeats as possible, but at least one. |
?? | Lazy ?. Zero repeats if possible, or one. |
{n}? | Lazy {n}. Equivalent to {n}. |
{n,}? | Lazy {n,}. As few repeats as possible, but at least n. |
{n,m}? | Lazy {n,m}. As few repeats as possible, but between n and m. |