Page 1 of 1

Conditional Regex in Replace not working?

Posted: Mon Jun 16, 2014 6:15 pm
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!

Re: Conditional Regex in Replace not working?

Posted: Mon Jun 16, 2014 8:39 pm
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