There is not so much backtracking going on I think.
I need to delete the whole xml-comment when it starts with the space+HINT. I think the fastest way is:
The ".*?" should do minimal matching, i.e. stopping as soon as the string-so-far is followed by the litteral space-dash-dash-greaterthan. This (should) makes it do no backtracking at all, I believe. I do not think I can make it faster, or am I wrong?s/<!-- HINT.*? -->//
Also the removal of the initial BOM should not lead to much backtracking. The regex engine should look at most at one character ahead in this case (I think).
And note that the whole regex was anchored at the beginning of the string too; again leading to much less work.s/^\x{feff}*//
I'll just wait for CentOS 6.x to come out, which has perl5.10, and until then just split up the regex. Good enough for me.
In reply to Re^2: Very slow regex substitution on Unicode string
by pbijnens
in thread Very slow regex substitution on Unicode string
by pbijnens
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |