$& returns the entire matched string $` returns everything before the matched string $' returns everything after the matched string $1 refers to the first group, outside the pattern $2 refers to the second group, outside the pattern $3 ... \1 refers to the first group, inside the pattern \2 refers to the second group, inside the pattern \3 ...