Look-around and multi-line support in Find/Replace
Are you missing a feature? Request its implementation here.
-
- Posts: 48
- Joined: Thu Mar 12, 2009 10:27 pm
Look-around and multi-line support in Find/Replace
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
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

-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Look-around and multi-line support in Find/Replace
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
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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 48
- Joined: Thu Mar 12, 2009 10:27 pm
Re: Look-around and multi-line support in Find/Replace
Thanks for the previous fix.
As an example of the multi-line issue, consider this preformatted XML fragment:
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:
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.
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>
Code: Select all
<note>(.*?)</note>
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>
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Look-around and multi-line support in Find/Replace
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
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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 48
- Joined: Thu Mar 12, 2009 10:27 pm
Re: Look-around and multi-line support in Find/Replace
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
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
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Look-around and multi-line support in Find/Replace
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
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
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service