Page 1 of 1
Look-around and multi-line support in Find/Replace
Posted: Wed May 20, 2009 10:46 pm
by solarian
I know these are both already on the enhancement list, but I'd like to draw attention to these two for support in Find/Replace with regular expressions.
Firstly, Perl "look-around" assertions currently work alright with Find, but produce an error if one tries to replace the found text with anything.
Secondly, multi-line support (i.e., the regex 's' pattern modifier) is lacking in Find/Replace with regex, which is pretty crucial when OxygenXML's formatting of XML adds lots of newlines. The only way to deal with this is to remove all newlines from a document before doing Find/Replace, which isn't a massive problem but it is an inconvenience. Given that OxygenXML treats \x0A as whitespace by default, the default for Find/Replace should be with the 's' modifier IMHO, otherwise a pattern that matches before using Format/Indent will stop working afterwards, which isn't terribly helpful.
Otherwise OK

Re: Look-around and multi-line support in Find/Replace
Posted: Wed May 20, 2009 10:48 pm
by solarian
P.S. Obviously, removing newlines in a long document causes a massive performance hit, so actually it can be a problem.
Re: Look-around and multi-line support in Find/Replace
Posted: Thu May 21, 2009 3:42 pm
by Radu
Hello,
The "look-around" issues have been addressed and the fix should be available in the next minor version(10.3).
As for the multi-line support can you give us an example of a use case?
Regards,
Radu
Re: Look-around and multi-line support in Find/Replace
Posted: Fri May 22, 2009 2:57 am
by solarian
Thanks for the previous fix.
As an example of the multi-line issue, consider this preformatted XML fragment:
Code: Select all
<p>This is a sample paragraph<note>ety. <foreign
xml:lang="grc">παραγραφη</foreign>
</note> in an imaginary document.</p>
If we wanted to find the <note> element we might use this:
but it would fail because of the line breaks, which aren't included in the definition of the '.' meta-character unless one sets the 's' pattern modifier. Obviously, this is a problem if you want to keep your XML pretty with lots of line breaks.
For comparison, the regex would work on this reformatted, but equivalent, XML:
Code: Select all
<p>This is a sample paragraph<note>ety. <foreign xml:lang="grc">παραγραφη</foreign></note> in an imaginary document.</p>
The fact that Perl (and presumably Java) defaults to the above behaviour is rather inappropriate for XML, where line breaks aren't treated differently from other whitespace, and particularly inappropriate in OxygenXML where line breaks are essential for performance reasons.
Re: Look-around and multi-line support in Find/Replace
Posted: Mon May 25, 2009 5:28 pm
by Radu
Hello,
We will consider adding an option which will allow '.' to also match line breaks however this most probably will not be the default behavior.
The reason is, in some cases, you may want to preserve the white spaces(space="preserve") and this feature would interfere and probably lead to unwanted results.
Regards,
Radu
Re: Look-around and multi-line support in Find/Replace
Posted: Tue May 26, 2009 4:36 am
by solarian
Hi,
I understand your reluctance to change the default behaviour; but with respect to adding an option to allow '.' to match line breaks, I think this is an essential part of regex support.
Best wishes,
Ian
Re: Look-around and multi-line support in Find/Replace
Posted: Fri Dec 11, 2009 10:50 am
by tavy
Hello Ian,
An option to allow '.' to also match line terminators has been added('Dot matches all') and will be available starting with the next minor version of <oXygen/> XML Editor (v11.1).
Best Regards,
Octavian Nadolu
Re: Look-around and multi-line support in Find/Replace
Posted: Fri Dec 11, 2009 12:37 pm
by solarian