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:
-
\u or \U, respectively, to change a single character or all characters to uppercase
-
\l or \L, respectively, to change a single character or all characters to lowercase
-
\n or \x{ddd}, for example, for a specific PCRE character code
For details about the PCRE dialect, see https://www.pcre.org/current/doc/html/pcre2syntax.html.
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