/\s0(1+)/ matches a "whitespace" character followed by a zero and one or more 1s -- the set of ones is stored in \1 (and $1)
|
/[0-9]\.0\D/ matches "the answer is 1.0 exactly" but not "the answer is 1.00" because of \D
-
In first case, $` is "the answer is ", $& is "1.0 " and $' is "exactly"
|
/a.*c.*d/ matches "axxxxcxxxxcdxxxxd" with
-
$` and $' as null and $& as full string (because greedy)
|
/(a.*b)c.*d/ matches "axxxxbcxxxxbd" with
-
\1 as "axxxxb" -- note backtracking as greedy (a.*b) first matches to "axxxxbcxxxxb" but then tries again when following c.*d fails to match
|