Regex to capture everything before first optional string

前端 未结 5 709
旧时难觅i
旧时难觅i 2020-12-16 02:20

I want to capture a pattern upto but not including the first instance of an optional other pattern with preg_match, eg:

ABCDEFGwTW$%                                  


        
5条回答
  •  北海茫月
    2020-12-16 02:58

    Another way to do it:

    $str = 'Q$TQ@#%GEFGw35hqb';
    $res = preg_split('/EFG/', $str);
    print_r($res);
    

提交回复
热议问题