Tinderbox v10 Icon

String.captureNumber([targetAttributeStr])


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Data Type Returned: 

Operator First Added: 

Operator in Current Baseline: 

Operator Last Altered: 

Operator Has Optional Arguments: 

 Function  [other Function type actions]

 Item  [operators of similar scope]

 Stream parsing  [other Stream parsing operators]

 String [about String data type]

 v9.1.0

 Baseline

 As at baseline

 [More on optional operator arguments]


Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses


String.captureNumber("targetAttribute")

String.captureNumber()

String.captureNumber

Searches forward from the start of String and matches the a detected number up to the first non-number character, optionally storing that number in the attribute specified targetAttributeStr, a quoted name of an attribute. It then returns the string that follows that number (to any left side recipient) whilst the String is advanced to a position after the number. The operator fails if the match is empty or entirely white space, with no result.

A number is assumed to be any character continuous sequence of one or more number characters between 0–9 (zero through nine). Formatted numbers will not be fully matched. Any further text after the number is ignored, both for the capture and advancing the String.

If the targetAttributeStr is omitted the String is advanced to after the number without any data being saved.

The value given for targetAttributeSt can be:

For example, if the string is "1234 items":

$Result = $Result=$Text.captureNumber("SomeAttribute");

The value of $SomeAttribute is "1234" $Result holds " items". But if the stream is "1,234 items", $Result holds "1" and $SomeAttribute holds ",234 items" as the comma means the first detected number stops at '1'.


See also—notes linking to here: