Fix memory leaks in the way pcre is used.
Merge branch 'release_31' into development

Fix memory leaks in the way pcre is used.