Regex replacement crash

Having trouble installing Oxygen? Got a bug to report? Post it all here.
dsewell
Posts: 125
Joined: Mon Jun 09, 2003 6:02 pm
Location: Charlottesville, Virginia USA

Regex replacement crash

Post 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.
Radu
Posts: 9436
Joined: Fri Jul 09, 2004 5:18 pm

Re: Regex replacement crash

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
dsewell
Posts: 125
Joined: Mon Jun 09, 2003 6:02 pm
Location: Charlottesville, Virginia USA

Re: Regex replacement crash

Post 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
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Regex replacement crash

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply