Bug #33321 Fix for invalid regular expressions. Patch committed with modifications. Submitted by: James Shaw <hertzsprrrung.at.btopenworld.com>