Skip to main content

next_char

An iterator that yields the next character from "pattern_iter", respecting escape sequences. An escaped character is replaced by a representative of its class (e.g. \w - > "x"). If the escaped character is one that is skipped, it is not returned (the next character is returned instead).

Yield the next character, along with a boolean indicating whether it is a raw (unescaped) character or not.

def next_char(
input_iter: iterator
) - > iterator

An iterator that yields the next character from "pattern_iter", respecting escape sequences. An escaped character is replaced by a representative of its class (e.g. \w - > "x"). If the escaped character is one that is skipped, it is not returned (the next character is returned instead).

Parameters

NameTypeDescription
input_iteriteratorAn iterator yielding characters from a regex-like pattern string to be processed for escape sequences.

Returns

TypeDescription
iteratorYields a tuple containing the next character (as a string) and a boolean indicating whether it is a raw (unescaped) character or not.