atto/text
Functions for parsing over strings.
Functions
pub fn match(
regex: String,
) -> Parser(String, String, String, a, b)
Parse a regex, returning the matched string.
Zero-length matches will fail.
Note that a literal backslash in the regex must be double-escaped,
such as \\\\b
to match the literal string \b
rather than a word boundary.
Note that zero-width matches can be dangerous, as they can cause infinite loops.
Examples
text.match("[0-9]+(\\.[0-9]*)?")
|> atto.run(text.new("123.456"), Nil)
|> atto.map(float.parse)
|> atto.map(result.unwrap(0.0))
// -> Ok(123.456)