Method _Stdio.Buffer()->match()


Method match

__deprecated__ string(8bit)|int|float|array match(string(8bit) format)

Description

Reads data from the beginning of the buffer to match the specifed format, then return the match.

The non-matching data will be left in the buffer.

This function is very similar to sscanf, but the result is the sum of the matches. Most useful to match a single value.

Returns

Returns the sum of the matching %-expressions, "" if a prefix (but no %-expression) matches and UNDEFINED on mismatch. Note that the addition may throw errors.

Note

Prior to Pike 9.0 0 was returned on mismatch and format was returned on a prefix match.

Example
// Get the next whitespace separated word from the buffer.
    buffer->match("%*[ \t\r\n]%[^ \t\r\n]");
    // Get the next integer as a string.
    buffer->match("%0s%d");
Deprecated

Replaced by sscanf.

See also

sscanf(), sscanf(), array_sscanf()