开发者

How do I tell pyparsing to discard parts of the parsed string?

开发者 https://www.devze.com 2023-03-28 15:22 出处:网络
I\'m writing a parser for some marked-up data,开发者_如何学Go and I\'d like to get pyparsing to discard things like start and end tags in the final result, leaving just the data.

I'm writing a parser for some marked-up data,开发者_如何学Go and I'd like to get pyparsing to discard things like start and end tags in the final result, leaving just the data.

Can I do this, or do I just have to name the value appropriately and pull them out manually?


"Suppress" is probably what you want. You can use the Suppress class explicitly, as in dont_care = Suppress(Word(alphas)) or call suppress() on any expression, dont_care = Word(alphas).suppress(). This will suppress the matched tokens from appearing in the parsed output.

0

精彩评论

暂无评论...
验证码 换一张
取 消