|
The backslash is still considered escape at string constructor level. It is discarded before it arrives to gsub. Then gsub does not even know it was there and interprets the ^ as negating next char (it needs at least one). Anytime you want a backslash in a string just insert it twice.