go to previous page   go to home page   go to next page



The new expression matches the same set of strings as the previous one, but does not capture the prefix of X characters.

Reluctant Quantifier

Regular Expression
Group 0
Group 1 Group 2 Group 3 Group 4

An quantifier in a regular expression may be greedy (the default), reluctant, or possesive. A reluctant quantifier does this:

An quantifier is made reluctant by appending a question mark. The expression X+? matches X one or more times, but matches as few X as it can without preventing other quantifier from matching. For example, when the expression


matches the string


the reluctant X+? could potentially match the entire string. But it matches as little as possible: the first X . The final [A-Z]+ of the expression matches the rest the string.

Reluctant quantifier are sometimes called lazy quantifier, because they match as little as possible.


Here is a string: XXXXX

What parts of the string match the capture group in the following expressions?