fixes #42, #43. #45. and #60

Contains fixes for PCRE related issues such as handling of invalid regular expressions, and evaluation of the regex_capture and escape_regex functions.