escape boundary inside regex

The boundary can have characters that are valid for regular expressions (e.g.
+), which cause the substitution to fail, so must be escaped.