Operator Type:
Operator Scope of Action:
Operator Purpose:
Data Type Returned:
Operator First Added:
Operator in Current Baseline:
Operator Last Altered:
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
String.expect(matchStr)
The operator tests if the String begins with the matchStr string with the following results:
- success: operator returns the rest of string that follows matchStr.
- failure: nothing is returned
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.
See also—notes linking to here: