This version is out of date, covering development from v9.0.0 to v9.3.0. It is maintained here only for inbound reference links from elsewhere. It is no longer actively updated.

Jump to the current version of aTbRef

Tinderbox v9 Icon

String.extract("regex")


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Altered: 

 Function   [other Function type actions]

 Item   [operators of similar scope]

 Data manipulation   [other Data manipulation operators]

 9.1.0

 


String.extract("regex")

The operator returns the first matched subexpression of a quote-enclosed regular expression regex 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().