".*?"
Regular Expression | |||
String | |||
Group 0 | |||
Group 1 | Group 2 | Group 3 | Group 4 |
Any quantifier can be made reluctant.
Reluctant Quantifiers match the minumum number of X needed | |
---|---|
Quantifier | Description |
X?? | zero or one X |
X*? | zero or more X |
X+? | one or more X |
X{n}? | exactly n X |
X{n,}? | n or more X |
X{n,m}? | n up to m X |
For example, X{2,5}?
will match between two and five X,
but will try to match as few as possible
The expression X{2}?
must match exactly two X
and is equivalent to X{2}
.
Here is a string: XXXXXrats
What parts of the string match the capture group in the following expressions?
(X{2,5})\w*
(X{2,5}?)\w*
(X*?)\w*