Regular Expressions Breaking

Having trouble installing Oxygen? Got a bug to report? Post it all here.
eBook_Creator
Posts: 2
Joined: Mon Jun 17, 2013 6:35 pm

Regular Expressions Breaking

Post by eBook_Creator »

I've just upgraded to Oxygen XML Author version 15.0 today and am now having trouble using the same global search/replace regular expressions that worked flawlessly in version 14.

A simple regular expression like:

Text fo find:

Code: Select all

(Hello)
Replace with:

Code: Select all

\1
Does exactly what you expect it would do when I use the Find/Replace command for individual files (it replaces the word "Hello" with itself). However, when I use the Find/Replace in Files command, the same code will replace all instances of "Hello" with the number "1".

Am I missing something here? Any help would be appreciated!
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Regular Expressions Breaking

Post by adrian »

Hello,

Thank you for letting us know about this problem.

Unfortunately this is a bug introduced in v15.0 of Oxygen. \1 is considered '1' (escaped) when used in the Replace with field from the Find/Replace in Files dialog.
I have logged this to our issue tracking tool and it will be analyzed and resolved in the next maintenance build of Oxygen v15.0. We will notify this thread when the bugfix becomes available.

Meanwhile, note that there is a simple workaround for this problem, you can use $1 instead of \1.
$i has the same significance as \i, "match of the capturing group i".

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
eBook_Creator
Posts: 2
Joined: Mon Jun 17, 2013 6:35 pm

Re: Regular Expressions Breaking

Post by eBook_Creator »

Hi Adrian,

Thank you for your quick response, and thank you for providing a perfect solution!

I'm hoping to follow up with another difference in search/replace behavior I noticed between v14 and v15. In v14 I could select multiple lines of code, use command+f, and the code I had highlighted would automatically populate the "Text to find:" box. Now, this no longer seems to be the case.

I can copy and paste the text, sure, but the aforementioned method was very convenient when I had the "Regular expression" check box checked, because it automatically escaped regular expression characters, and converted new lines to "\n" expressions.
Costin
Posts: 846
Joined: Mon Dec 05, 2011 6:04 pm

Re: Regular Expressions Breaking

Post by Costin »

Hello,

Yes, the Find and Replace mechanism was changed for the multiple lines selection, as a result of many user requests.
Now, when a user has a multi-line selection, Find/Replace is actually setting those multiple lines as the scope for the current search. So it searches for the user input inside the multi-line selection.

However, now we have some requests from our users to change this behavior to the previous one, so I've added your vote to this feature request in our issue tracking system.

This will be analyzed and, if found appropriate, it could be implemented in a future version of oXygen.

Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support
Radu
Posts: 9449
Joined: Fri Jul 09, 2004 5:18 pm

Re: Regular Expressions Breaking

Post by Radu »

Hi,

The workaround to obtain the old behavior would be to first press Ctrl-F (without any selection) and have the dialog appear.
Then keeping the dialog opened (it is not modal) you focus again in the Text page, select the lines and press Ctrl-F again. The dialog text to find area should now have the selected content escaped (if the regexp checkbox is enabled).

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9449
Joined: Fri Jul 09, 2004 5:18 pm

Re: Regular Expressions Breaking

Post by Radu »

Hi,

Just to update the thread, the original reported issue should work again in 15.1.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply