setExtendedReplace

setExtendedReplace(enable: Boolean): JadeRegexPattern;

This fluent‑style method returns its own modified receiver, to allow call chaining. (By default, the backslash character is not a special character.)

Call the setExtendedReplace method of the JadeRegexPattern class with the enable parameter set to true to specify that the backslash character (\) is made a special character instead of only the dollar character ($).

When the extended replace functionality is set, you can use:

The following is an example of the setExtendedReplace method.

setExtendedReplaceExample();
constants
    Text = "ThIs Is sOmE MiStAkE WitH ThE CaPs";
    PatternStr = "\w+";
    // conditionally replace the whole match with the whole match lower‑cased
    Replacement = "${0:+\L$0}";
vars
    pattern : JadeRegexPattern;
begin
    create pattern;
    pattern.setExtendedReplace(true).compile(PatternStr);
    write pattern.replaceAll(Text, Replacement);
    // "this is some mistake with the caps"
epilog
    delete pattern;
end;

Extending the replace functionality also adds more flexibility to the substitution of capture groups. The syntax is similar to that used by Bash script, as follows.

${<n>:-<string>}
${<n>:+<string1>:<string2>}

By default, only the dollar character ($) is a special character in a replace string.

You can set the extended replace functionality after you call the compile method.

2020.0.01 and higher