[−][src]Function nom_supreme::tag::complete::tag_no_case
pub fn tag_no_case<T, I, E>(tag: T) -> impl Clone + Fn(I) -> IResult<I, I, E> where
T: InputLength + Clone,
I: InputTake + Compare<T>,
E: TagError<I, T>,
Parser recognizing a fixed pattern, called a tag. If the front of the
input data matches the tag
, case insensitively, that part of the
input will be returned. Records the tag in the error in the event of a
parse failure via TagError
.
Example
use cool_asserts::assert_matches; use nom_supreme::tag::complete::tag_no_case; use nom_supreme::error::{ErrorTree, BaseErrorKind, Expectation}; fn parse_hello(s: &str) -> IResult<&str, &str, ErrorTree<&str>> { tag_no_case("hello")(s) } assert_matches!( parse_hello("HELLO, WORLD!"), Ok((", WORLD!", "HELLO")), ); assert_matches!( parse_hello("something"), Err(Err::Error(ErrorTree::Base { location: "something", kind: BaseErrorKind::Expected(Expectation::Tag("hello")), })) ); assert_matches!( parse_hello("HEL"), Err(Err::Error(ErrorTree::Base { location: "HEL", kind: BaseErrorKind::Expected(Expectation::Tag("hello")), })) );