setDuplicateNames

setDuplicateNames(enable: Boolean): JadeRegexPattern;

This fluent‑style method returns its own modified receiver, to allow call chaining. (By default, prefixes are not enabled.)

Call the setDuplicateNames method of the JadeRegexPattern class with the enable parameter set to true to specify that a pattern can have multiple named groups with the same name.

The following is an example of a setDuplicateNames operation with a customized pattern.

setDuplicateNamesExample();
constants
    PatternStr = "^(?'numbers'\d{4})$|^(?'numbers'\d{8})$";
    Text = "12345678";
    CaptureName = "numbers";
vars
    pattern : JadeRegexPattern;
    match : JadeRegexMatch;
    expectedCapture : JadeRegexCapture;
begin
    create pattern;
    pattern.setDuplicateNames(true)
           .setExplicitCapture(true)
           .compile(PatternStr);
    pattern.match(Text, match);
    write match.at(1).hasValue(); // false
    write match.at(2).hasValue(); // true
    write match.getCaptureByName(CaptureName).value; // 12345678
epilog
    delete match;
    delete pattern;
end;

The ability to have duplicate names must be set to true before you call the compile method.

2020.0.01 and higher