Function take_until1

fn take_until1<T, I, Error: ParseError<I>>(tag: T) -> impl FnMut(I) -> crate::internal::IResult<I, I, Error>
where
    I: Input + FindSubstring<T>,
    T: Clone

Returns the non empty input slice up to the first occurrence of the pattern.

It doesn't consume the pattern.

Streaming Specific

Streaming version will return a Err::Incomplete(Needed::new(N)) if the input doesn't contain the pattern or if the input is smaller than the pattern.

Example

# use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
use nom::bytes::streaming::take_until1;

fn until_eof(s: &str) -> IResult<&str, &str> {
  take_until1("eof")(s)
}

assert_eq!(until_eof("hello, worldeof"), Ok(("eof", "hello, world")));
assert_eq!(until_eof("hello, world"), Err(Err::Incomplete(Needed::Unknown)));
assert_eq!(until_eof("hello, worldeo"), Err(Err::Incomplete(Needed::Unknown)));
assert_eq!(until_eof("1eof2eof"), Ok(("eof2eof", "1")));
assert_eq!(until_eof("eof"),  Err(Err::Error(Error::new("eof", ErrorKind::TakeUntil))));