escape regular expressions

Escape characters which are part of the regular expression syntax. This should fix #1098 in stable45.