Operator Type:
Operator Scope of Action:
Operator Purpose:
Data Type Returned:
Operator First Added:
Operator in Current Baseline:
Operator Last Altered:
Operator Uses Regular Expressions:
Function [other Function type actions]
Item [operators of similar scope]
Data manipulation [other Data manipulation operators]
String [about String data type]
v9.1.0
Baseline
10.1.0
String.extract(regexStr)
The operator returns the first matched subexpression of a quote-enclosed regular expression regexStr in the source String. If the regular expression has no subexpressions, the entire match is returned up to the end of the current line/paragraph, i.e. the first line break character encountered.
For example, take a String which is the $Text "We are very tired, Harrison! #things #Memes #August":
$MyString = $Text.extract("[A-Z][A-Za-z+]");
this returns "We" as that is the first match (although there are others). This sort of use is the presumed most likely used of this operator.
If we amend the regex
$MyString = $Text.extract("#([A-Z][A-Za-z+])");
it now returns "Memes" (the first hash tag starts with a lowercase letter does not match).
If multiple matches are expected/wanted, see String.extractAll().
String.extract(regex[, caseInsensitiveBln])
String.extract() now accepts an optional boolean second argument caseInsensitiveBln. If that argument is true
, the regex argument's regular expression search is case-insensitive. The default value is false
respecting the pre-existing behaviour.
From 10.1.0, .extract() recognises ^
and $
regex codes as applying to the start and end of a line within a multiline string. Therefore, ^ and $ can apply to line boundaries within a multiline string.
See also—notes linking to here: