PHP Regex to match multiline

后端 未结 1 1875
小蘑菇
小蘑菇 2021-01-28 12:10

i need to build a pattern to match a multiline code

    $data[\'infos\'] = array();
    foreach ($infos as $info) {
        $data[\'infos\'][] = array(
                  


        
1条回答
  •  -上瘾入骨i
    2021-01-28 12:20

    If a simple pattern would be sufficient depends on how your input could look like.

    $re = '~\Q$data[\'infos\'][]\E.*?\);~s';
    
    • \Q...\E is used to match literally (also could escape the brackets/dollar).
    • .*? in single line mode (s flag) matches lazily any amount of any character.

    See demo at regex101 or php demo at eval.in

    0 讨论(0)
提交回复
热议问题