whitespace
Tries to match one or more whitespaces (regex: /[\r\n\t\f\v ]+/
).
Available since: v1.0.0-alpha.1
Type declaration
const whitespace: (name?: string) => Parser;
Example
In this example we are going to parse a newline (\n
), an arbitrary word followed by another newline.
import { sequenceOf, whitespace, word } from "rudus";
const parser = sequenceOf([whitespace(), word(), whitespace()]);
const result = parser.run(`Hello`);
The result
of the parser above will be:
{ "input": "Hello", "isError": false, "offset": 7, "result": ["", "Hello", ""]}