regex
regexFullMatch(string pattern, string input)
Matches the entire input against the pattern (anchored start and end). If there’s no match, returns null
. If there’s a match, returns a JSON object which has the following structure:
-
string
- the matched string; -
captures
- array of captured subgroups in the match, if any; -
namedCaptures
- map of named subgroups, if any;
Example
ds.regex.regexFullMatch(@'h(?P<mid>.*)o', 'hello')
{ "string": "hello", "captures": [ "ell" ], "namedCaptures": { "mid": "ell" } }
regexPartialMatch(string pattern, string input)
Matches the input against the pattern (unanchored). If there’s no match, returns null
. If there’s a match, returns a JSON object which has the following structure:
-
string
- the matched string; -
captures
- array of captured subgroups in the match, if any; -
namedCaptures
- map of named subgroups, if any;
Example
ds.regex.regexPartialMatch(@'e(?P<mid>.*)o', 'hello')
{ "string": "ello", "captures": [ "ll" ], "namedCaptures": { "mid": "ll" } }
regexScan(string pattern, string input)
Finds all matches of the input against the pattern. If there are any matches, returns an array of JSON objects which have the following structure:
-
string
- the matched string; -
captures
- array of captured subgroups in the match, if any; -
namedCaptures
- map of named subgroups, if any;
Example
ds.regex.regexScan(@'(?P<user>[a-z]*)@(?P<domain>[a-z]*).org', 'modus@datasonnet.org,box@datasonnet.org')
[ { "string": "modus@datasonnet.org", "captures": [ "modus", "datasonnet" ], "namedCaptures": { "domain": "datasonnet", "user": "modus" } }, { "string": "box@datasonnet.org", "captures": [ "box", "datasonnet" ], "namedCaptures": { "domain": "datasonnet", "user": "box" } } ]
regexQuoteMeta(string str)
Returns a literal pattern string for the specified string.
Example
ds.regex.regexQuoteMeta(@'1.5-2.0?')
"1\\.5-2\\.0\\?"