match

match(text:            String;
      pattern:         String;
      ignoreCase:      Boolean;
      explicitCapture: Boolean;
      match:           JadeRegexMatch io): Boolean;

The match method of the JadeRegex class determines if the specified text completely matches the specified pattern. This is a more‑capable form of the isMatch method, as it records any match, including any capture groups specified in the pattern, as a JadeRegexMatch object. This method returns true if the whole of the text string matches the specified pattern; otherwise it returns false.

The match method parameters are described in the following table.

Parameter Description
text Text string against which to determine a match.
pattern Regex pattern string.
ignoreCase Specifies whether matching is case-sensitive.
explicitCapture Specifies whether to generate JadeRegexCapture objects for each sub‑match if your pattern contains capture groups.
match

JadeRegexMatch contains details about the match such as all capture groups for the match and the position within the text of a successful match.

It is your responsibility to delete the JadeRegexMatch object when you are finished with it.

You can explicitly create and pass a JadeRegexMatch object in which to store the match details or you can pass just a null reference and let the method itself create and populate a JadeRegexMatch object. This allows for minimal overhead for invoking such calls.

The following is an example of a match type method.

typeMatchExample();
vars
    text, pattern, output : String;
    isValidUrl : Boolean;
    match : JadeRegexMatch;
begin
    text := "https://www.jadeworld.com/";
    pattern := "(http(?'isSecure'[s]?):\/\/)([\w.]+)([\w\/.])*";
    isValidUrl := JadeRegex@match(text, pattern, true, true, match);
    if isValidUrl then
        output := match.value & " is a valid ";
        if match.getCaptureByName('isSecure').value <> '' then
            output := output & "and secure ";
        endif;
        output := output & "url.";
    else
        write text & " is not a valid url.";
    endif;
    write output;
    /* writes https://www.jadeworld.com/ is a valid and secure url. */
end;

2020.0.01 and higher