Skip to content

Proposal: extend usage of nom::sequence::delimited with take_until_unbalanced #1253

@getreu

Description

@getreu

For my parse-hyperlinks - crate I implemented a parser for balanced nested brackets like in u<<>>r<>.

It is called parse_hyperlinks::take_until_unbalanced and it is designed to work with nom::sequence::delimited:

use nom::bytes::complete::tag;
use nom::sequence::delimited;
use parse_hyperlinks::take_until_unbalanced;

let mut parser = delimited(tag("<"), take_until_unbalanced('<', '>'), tag(">"));
assert_eq!(parser("<<inside>inside>abc"), Ok(("abc", "<inside>inside")));

I think the use case is so general, that you might want to integrate it into Nom. I implemented the code for &str, but as it only uses find, it should be easy to generalize. You can find my implementation here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions