Will this expression
match the string $44.95 and capture the dollar and cents amount
No. The or operator
| has low precidence.
The expression means
|Group 1||Group 2||Group 3||Group 4|
As we have seen, quantifiers are greedy. This means that:
For example, when the expression
matches the string
X+ could potentially match
the entire string.
But it only matches the first three characters so that
[A-Z]+ of the expression can match the final X of the string.
The strings matched by the example expression are:
strings that start with a prefix of one or more characters X, followed by one or more characters A through Z.
Find another regular expression that matches these same strings. (And use the applet to confirm that it works.)