Parsing of parenthesis with sed using regex

前端 未结 3 1935
我寻月下人不归
我寻月下人不归 2021-01-14 04:25

I am looking for a command in sed which transforms this input stream:

dummy
(key1)
(key2)dummy(key3)
dummy(key4)dummy
dummy(key5)dummy))))dummy
         


        
3条回答
  •  梦毁少年i
    2021-01-14 04:55

    In Perl, you can use Marpa, a general BNF parser — the parser code is in this gist.

    BNF parser is arguably more maintainable than a regex. Parens around grammar symbols hide their values from the parse tree thus simplifying the post-processing.

    Hope this helps.

提交回复
热议问题