Recognize undos map
Author: tdymelCreated Dec 10, 2025Updated Mar 18, 2026
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
Source: rust-bakery/nom