Matching balanced parenthesis in Perl regex

前端 未结 6 1644
后悔当初
后悔当初 2021-01-12 08:52

I have an expression which I need to split and store in an array:

aaa=\"bbb{ccc}ffffd\" { aa=\"bb,cc\" { a=\"b\", c=\"d\" } }, aaa=\"bbb{}\" { aa=\"b}b\" }, aa         


        
6条回答
  •  臣服心动
    2021-01-12 09:39

    Use the perl module "Regexp::Common". It has a nice balanced parenthesis Regex that works well.

    # ASN.1
    use Regexp::Common;
    $bp = $RE{balanced}{-parens=>'{}'};
    @genes = $l =~ /($bp)/g;
    

提交回复
热议问题