Function escaped

fn escaped<I, Error, F, G>(normal: F, control_char: char, escapable: G) -> impl FnMut(I) -> crate::internal::IResult<I, I, Error>
where
    I: Input + Clone + crate::traits::Offset,
    <I as Input>::Item: crate::traits::AsChar,
    F: Parser<I, Error = Error>,
    G: Parser<I, Error = Error>,
    Error: ParseError<I>

Matches a byte string with escaped characters.

Example

# use nom::{Err, error::ErrorKind, Needed, IResult};
# use nom::character::complete::digit1;
use nom::bytes::streaming::escaped;
use nom::character::streaming::one_of;

fn esc(s: &str) -> IResult<&str, &str> {
  escaped(digit1, '\\', one_of("\"n\\"))(s)
}

assert_eq!(esc("123;"), Ok((";", "123")));
assert_eq!(esc("12\\\"34;"), Ok((";", "12\\\"34")));