Tinderbox v9 Icon

String.expectWord()


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

 Function  [other Function type actions]

 Item  [operators of similar scope]

 Stream parsing  [other Stream parsing operators]

 Baseline

 As at baseline


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


String.expectWord()

String.expectWord

If the string begins with one or more contiguous character(s) that could be interpreted as a word the String stream cursor skips to the end of that sequence and parsing continues.

What constitutes a word? This operator captures text from the current position up to (but not including) the next character that is a digit, whitespace, or punctuation.

For example:

vText = $Text.expectWord(); 

Tests that the next characters in the stream are not non-word, and advances the stream beyond the detected word. Otherwise, it fails and the cursor does not advance. Either way, variable vText receives the resulting text stream as would any operator chained to .expectWord() unless a failure occurs in which case chained operators are not processed.

If the stream passed in is "Hello world" then 'Hello' is detected and the cursor returns " world" (note the leading space). But if the stream passed in is " Hello world" (note the leading space), no word is detected and the cursor does not advance.

The presumption for use of this operator is as an assist to help ensure to-be-captured content is correctly detected. Essentially, this is a 'if' style test: if the test is correct proceed, else the cursor remains where it is for any possible chained stream parsing operators.