oni_comb_parser_rs::prelude

Function regex

Source
pub fn regex<'a>(pattern: &str) -> Parser<'a, char, String>
Expand description

Returns a Parser that parses a string that match a regular expression.
正規表現に合致する文字列を解析するParserを返す。

  • pattern: a regular expression
  • pattern: 正規表現

§Example

use oni_comb_parser_rs::prelude::*;

let text: &str = "abcdef";
let input = text.chars().collect::<Vec<_>>();

let parser: Parser<char, String> = regex("[abc]+");

let result: ParseResult<char, String> = parser.parse(&input);

assert!(result.is_success());
assert_eq!(result.success().unwrap(), "abc");