Function is_a

fn is_a<T, I, Error: ParseError<I>>(arr: T) -> impl FnMut(I) -> crate::internal::IResult<I, I, Error>
where
    I: Input,
    T: FindToken<<I as Input>::Item>

Returns the longest slice of the matches the pattern.

The parser will return the longest slice consisting of the characters in provided in the combinator's argument.

It will return a Err(Err::Error((_, ErrorKind::IsA))) if the pattern wasn't met.

Example

# use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
use nom::bytes::complete::is_a;

fn hex(s: &str) -> IResult<&str, &str> {
  is_a("1234567890ABCDEF")(s)
}

assert_eq!(hex("123 and voila"), Ok((" and voila", "123")));
assert_eq!(hex("DEADBEEF and others"), Ok((" and others", "DEADBEEF")));
assert_eq!(hex("BADBABEsomething"), Ok(("something", "BADBABE")));
assert_eq!(hex("D15EA5E"), Ok(("", "D15EA5E")));
assert_eq!(hex(""), Err(Err::Error(Error::new("", ErrorKind::IsA))));