The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Match A String Until A Case Insensitive Tag With nom In Rust

TODO: Pull subtitle into page object
Code
//! ```cargo
//! [dependencies]
//! nom = "7.1.3"
//! ```

use nom::IResult;
use nom::multi::many_till;
use nom::character::complete::anychar;
use nom::bytes::complete::tag_no_case;

fn main() {
    let source = "the quick brown fox";
    let result = parse(source).unwrap().1;
    println!("{:?}", result);
}

fn parse(source: &str) -> IResult<&str, String> {
    let (source, result) = many_till(anychar, tag_no_case(" brown"))(source)?;
    let result: String = result.0.iter().collect();
    Ok((
        source,
        result
    ))
}
Results
"the quick"

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Match A String Until A Case Insensitive Tag With nom In Rust

See the second one if you want to keep the text

-- code
-- rust

//! ```cargo
//! [dependencies]
//! nom = "7.1.3"
//! ```

use nom::IResult;
use nom::multi::many_till;
use nom::character::complete::anychar;
use nom::bytes::complete::tag_no_case;

fn main() {
    let source = "the quick brown fox";
    let result = parse(source).unwrap().1;
    println!("{:?}", result);
}

fn parse(source: &str) -> IResult<&str, String> {
    let (source, result) = many_till(anychar, tag_no_case(" brown"))(source)?;
    let result: String = result.0.iter().collect();
    Ok((
        source,
        result
    ))
}

-- results/

"the quick"

-- /results


This is aimed at keeping the ending part


-- code
-- rust

//! ```cargo
//! [dependencies]
//! nom = "7.1.3"
//! ```

use nom::IResult;
use nom::multi::many_till;
use nom::character::complete::anychar;
// use nom::bytes::complete::tag_no_case;
// use nom::sequence::pair;
// use nom::bytes::complete::take_until;
use nom::bytes::complete::tag;
use nom::combinator::peek;

fn main() {
    let source = "the quick brown fox";
    let result = parse(source);
    dbg!(result.unwrap());
}

fn parse(source: &str) -> IResult<&str, String> {
    let (source, result) = many_till(anychar, peek(tag(" brown")))(source)?;
    let result: String = result.0.iter().collect();
    Ok((
        source,
        result
    ))
}

-- results/

[_active_nvim_run:18] result.unwrap() = (
    " brown fox",
    "the quick",
)

-- /results


-- categories
-- Rust 
-- Nom 

-- metadata
-- date: 2023-07-10 02:43:19
-- id: 2smzmtef
-- site: aws
-- type: post
-- status: scratch