Fixed escaped $ sign, explained regex in detail