QUANTIFIERS

One or more

+ matches the previous element one or more times in a row, as one match.

A quantifier applies to the element right before it. + means "one or more of that element, in a row."

See the difference on the text "I have 1200 apples". \d matches a SINGLE digit, so it finds four separate matches: "1", "2", "0", "0". Add the + and \d+ means "one or more digits in a row", so the whole run "1200" becomes ONE match.

"I have 1200 apples"
\d    matches  1  2  0  0   (four matches)
\d+   matches  1200          (one match)

Quantifiers are greedy: they grab as much as they can. \d+ on "1200" takes all four digits at once, never stopping early at just "1".

PRACTICE - 3 DRILLS 0/3 DONE
DRILL 1/3

Match every whole number as one match.

/ /
order 66 costs 1200
must match: "66" "1200"
7 of 9
must match: "7" "9"
no digits
must match nothing
DRILL 2/3- Words

Match each run of one or more lowercase letters.

/ /
abc 123 def
must match: "abc" "def"
a1b2c3
must match: "a" "b" "c"
42
must match nothing
DRILL 3/3- Versions

Match each version number like 1.2 or 10.4 as one match (digits, a dot, digits).

/ /
from 1.2 to 10.4
must match: "1.2" "10.4"
v3.0 released
must match: "3.0"
no version
must match nothing