Page 1 of 1
Regex replacement crash
Posted: Sat Mar 01, 2008 1:33 am
by dsewell
oXygen 9.1, standalone under Mac OS X
If I try the following regular expression find-and-replace:
Text to find: x*$
Replace with: [empty]
oXygen hangs and has to be killed externally. 'x' above can be any character.
Re: Regex replacement crash
Posted: Mon Mar 03, 2008 10:47 am
by Radu
Hello,
Thank you for reporting this issue.
The problem with the expression 'x*$' is that it can also match empty strings located at the end of line because of the x*(0-n occurrences of x). When using 'Replace all' there will always be a match of length 0 at the end of any line so the replace will get stuck in an infinite loop.
If x+(1-n occurrences of x) would have been used then this problem would not have occurred.
We have added an issue to our bug tracking tool and a detection/prevention of such situations will be implemented in the next minor version.
Meanwhile, the workaround is to avoid expressions that match empty strings combined with position markers like '^'(start of line) and '$'(end of line). In your case 'x+$' should solve the problem.
Regards,
Radu
Re: Regex replacement crash
Posted: Mon Mar 03, 2008 5:10 pm
by dsewell
The problem with the expression 'x*$' is that it can also match empty strings located at the end of line because of the x*(0-n occurrences of x). When using 'Replace all' there will always be a match of length 0 at the end of any line so the replace will get stuck in an infinite loop.
If x+(1-n occurrences of x) would have been used then this problem would not have occurred.
We have added an issue to our bug tracking tool and a detection/prevention of such situations will be implemented in the next minor version.
Meanwhile, the workaround is to avoid expressions that match empty strings combined with position markers like '^'(start of line) and '$'(end of line). In your case 'x+$' should solve the problem.
Right--I should have mentioned that the expression that I first used when the hang occurred was " *$" where I accidentally typed a single space instead of two spaces. This is an easy mistake to make. Thanks for logging the bug.
David
Re: Regex replacement crash
Posted: Mon May 19, 2008 3:35 pm
by adrian
Hello,
We have implemented a fix for preventing such situations. The fix will be available in the next minor version(9.3).
Regards,
Adrian