Inconsistent regular expression behavior with Find/Replace
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 482
- Joined: Thu Jan 23, 2014 2:29 pm
- Location: Hamburg
- Contact:
Inconsistent regular expression behavior with Find/Replace
Post by Frank Ralf »
Hi,
I've noticed that the regular expressions do behave differently in Find/Replace within a single file and Find/Replace in Files, most notably the behavior of a point "." As the "Dot matches all" option (Perl's /s modifier) is missing from Find/Replace in Files this makes it quite cumbersome to write a regex which spans multiple lines in the source code.
Is there a workaround or do I have to use another editor for more complex regex find/replace operations across multiple files? It would be great, if Find/Replace in Files would provide the same options as the usual Find/Replace.
Kind regards,
Frank
I've noticed that the regular expressions do behave differently in Find/Replace within a single file and Find/Replace in Files, most notably the behavior of a point "." As the "Dot matches all" option (Perl's /s modifier) is missing from Find/Replace in Files this makes it quite cumbersome to write a regex which spans multiple lines in the source code.
Is there a workaround or do I have to use another editor for more complex regex find/replace operations across multiple files? It would be great, if Find/Replace in Files would provide the same options as the usual Find/Replace.
Kind regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com
parson AG
www.parson-europe.com
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Inconsistent regular expression behavior with Find/Repla
Hi,
The reason the option 'Dot matches all' (Perl's single line mode) is not readily available in Find Replace in Files is that it forces the entire document to be treated as a single line and loaded in memory, instead of searching the file incrementally. This can frequently lead to situations where the file would not fit the available memory.
For the Find/Replace in editor this doesn't make any difference since the file is already loaded in memory.
If you want to force that option, you can use the directive (?s) at the beginning of the regular expression.
I believe there is also the alternative solution of using '(.|\n)' in the expression instead of '.' with that option.
Regards,
Adrian
The reason the option 'Dot matches all' (Perl's single line mode) is not readily available in Find Replace in Files is that it forces the entire document to be treated as a single line and loaded in memory, instead of searching the file incrementally. This can frequently lead to situations where the file would not fit the available memory.
For the Find/Replace in editor this doesn't make any difference since the file is already loaded in memory.
If you want to force that option, you can use the directive (?s) at the beginning of the regular expression.
I believe there is also the alternative solution of using '(.|\n)' in the expression instead of '.' with that option.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 482
- Joined: Thu Jan 23, 2014 2:29 pm
- Location: Hamburg
- Contact:
Re: Inconsistent regular expression behavior with Find/Repla
Post by Frank Ralf »
Hi Adrian,
Thanks for the explanation and the pointers for a workaround. I will try that.
Kind regards,
Frank
Thanks for the explanation and the pointers for a workaround. I will try that.
Kind regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com
parson AG
www.parson-europe.com
-
- Posts: 482
- Joined: Thu Jan 23, 2014 2:29 pm
- Location: Hamburg
- Contact:
Re: Inconsistent regular expression behavior with Find/Repla
Post by Frank Ralf »
(?s) works like a charm and helps tremendously!
Many thanks again for your help,
Frank
Many thanks again for your help,
Frank
Frank Ralf
parson AG
www.parson-europe.com
parson AG
www.parson-europe.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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