Conditional Regex in Replace not working?

Having trouble installing Oxygen? Got a bug to report? Post it all here.
RIH
Posts: 3
Joined: Mon Jun 16, 2014 6:08 pm

Conditional Regex in Replace not working?

Post by RIH »

I'm trying to use a conditional regular expression in the Replace part of the Find/Replace dialog. I can't get it to work--it returns string literals rather than evaluating the condition. I'm using 15.1, which I understood from the documentation supports Perl 5 regex, so I'm not sure what I'm missing.

For example,

Find:

Code: Select all

(box)
Replace:

Code: Select all

$1(?(1)es)
replaces all instances of "box" with the string "box(?(1)es)".

Any pointers would be much appreciated!
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Conditional Regex in Replace not working?

Post by adrian »

Hi,

The documentation is somewhat misleading. It mentions Perl 5 regular expressions because they are more commonly known, but in reality Oxygen relies on the support provided by the Java regular expression implementation from java.util.regex.Pattern, as described here:
http://docs.oracle.com/javase/6/docs/ap ... ttern.html
(Look for 'Comparison to Perl 5')
While very similar with Perl 5 regular expressions, the Pattern implementation does have some limitations, one being that it does not support conditional constructs.

I've logged an issue for the documentation department to address this mistake.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply