regexp split string by commas and spaces, but ignore the inside quotes and parentheses

前端 未结 2 708
栀梦
栀梦 2020-12-11 22:25

I need split string by commas and spaces, but ignore the inside quotes, single quotes and parentheses

$str = \"Questions, \\\"Quote\\\",\'single quote\',\'co         


        
2条回答
  •  無奈伤痛
    2020-12-11 23:28

    This will work only for non-nested parentheses:

        $regex = <<

    The ++ and *+ will consume as much as they can and give nothing back for backtracking. This technique is described in perlre(1) as the most efficient way to do this kind of matching.

提交回复
热议问题