Using this regex instead will solve both of the problems I mentioned: `/^([^\\]|\\[^0-7])*\\([0-7])/`.