takeOnelineMath

fun Scanner.takeOnelineMath(accepts: Scanner.() -> Boolean = { true }): String?

Consumes a one-line math expression. It opens with a dollar sign and one space or tab and closes with one space or tab and a dollar sign; an inner dollar sign belongs to the expression as long as it is not adjacent to whitespace.

The closing delimiter is the first candidate accepts agrees with. In $ Math $expression $ the inner dollar sign looks like a closing delimiter, and only the caller's trailing rule can reject it.

Return

the expression between the delimiters, its spacing excluded, or null when none starts here

Parameters

accepts

run just past a candidate closing delimiter, returning whether what follows is acceptable