Tinderbox v9 Icon

String.expect(matchStr)


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


String.expect(matchStr)

The operator tests if the String begins with the matchStr string with the following results:

For example:

vText = $Text.expect("abc"); 

Tests that the next characters in the stream read from $Text is the sequence abc, and advances the stream beyond "abc". Otherwise, it fails and the cursor does not advance. Either way, variable vText receives the resulting text stream as would any operator chained to .expect() unless a failure occurs in which case chained operators are not processed.

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.