Signature
DValue regex_search(String pattern, String subject) DValue regex_search(String pattern, String subject, String flags)
Parameters
pattern : PCRE2 regular expression pattern
subject : string to search
flags : optional regex flags
return value : a DValue describing the first match
Searches subject for the first occurrence of pattern and returns structured match data.
Example:
Return shape:
matchedis a boolean.patternstores the original pattern.flagsstores the supplied flags, ordefault.matchis the full matched text when a match exists.startandendare byte offsets into the original string.capturesis a list of capture objects, with capture0representing the full match.namedmaps named capture groups to their captured text.named_offsetsmaps named capture groups toindex,start, andendmetadata.
Capture entries contain:
If no match is found, matched is false and match-specific fields are omitted.
Example
DValue match = regex_search("docs", "uce docs");
print(match["match"].to_string(), "\n");
Output
docs