Skip to content

Recognize undos map #1873

@tdymel

Description

@tdymel

I tried to match a format like string like this:
"This is a {{{arg}}} literal". I wanted it to replace the escaped character "{" using map, such that my end result would be:
"This is a {", "arg", "} literal"

Below the code I use to parse the literal, ie. "This is a {{" -> "This is a {"

recognize(many1(alt((
        map(tag("{{"), |_| "{"),
        map(tag("}}"), |_| "}"),
        is_not("{"),
    )))).parse(input);

The part without recognize would output: ["This is a ", "{"]
Recognize turns it into "This is a {{"

Version: 8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions