Thanks, so far I have only been able to resolve this issue by reverting the previous change. I have taken a look at several other PCRE implementations and unfortunately they vary quite a bit in the way they call PCRE, so it is difficult to know whether they can handle the above expressions correctly. I have also tried testing your expressions on several regex online testers (such as this one) and their results vary. Can you find an online regex tester that reproduces the desired behaviour? Are you sure that this should be the correct behaviour?