This version is out of date, covering development from v9.5.0 to v9.7.3. 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

Capture operators

The capture family of operators extract a chunk of information from the stream and store them in a target attribute. The target attribute may be the source of the stream, in which case the parse will cease at the first capture.

String.captureLine[("targetAttribute")]

Captures text from the current stream position, up to the next line ending or the end of the stream. The text is stored in the designated targetAttribute, and the stream advances to the character following the line break.

String.captureNumber[("targetAttribute")]

Captures a number from the current steam position, up to the next character that cannot be considered part of a number; the capture is passed targetAttribute. Advances the stream to that character. A failure occurs if the stream cannot be interpreted as a number.

String.captureWord[("targetAttribute")]

Captures text from the current stream position up to the next character that is a digit, whitespace, or punctuation; the capture is passed targetAttribute. Fails if the stream is empty or begins with a digit, whitespace, or punctuation.

String.captureTo[("string","targetAttribute")]

Stores the string up to but not including the designated literal string (it is not a regular expression) in the designated attribute, and returns the string that follows string. An alternative, that supports regex is String.extract().

String.captureToken[("targetAttribute")]

If the string contains a token specified by a prior parsing operator, the token itself is passed to targetAttribute. The stream is not advanced and any chained parsing continues from the same point.

String.captureRest[("targetAttribute")]

Captures the rest of the stream in as the value of targetAttribute, and returns the empty string.

String.captureXML

Attempts to parse the string as fully/partially XML and fails if unsuccessful. The parsed XML is saved as the current XML (stream) object. Essentially, this re-scopes the current stream so that it contains only the contents of the first section of XML detected within the original stream. The focus of the stream parsing is set to the beginning of the extracted XML code. Only one XML object may be current at any time. If the source stream contains multiple discrete XML code sections, only the first is detected/used.

String.captureJSON

Attempts to parse the string as fully/partially JSON and fails if unsuccessful. The parsed JSON is saved as the current JSON (stream) object. Essentially, this re-scopes the current stream so that it contains only the contents of the first section of JSON detected within the original stream. The focus of the stream parsing is set to the beginning of the extracted JSON code. Only one JSON object may be current at any time. If the source stream contains multiple discrete JSON code sections, only the first is detected/used.