php: regex remove bracket in string

前端 未结 4 2022
醉话见心
醉话见心 2021-01-22 05:16

similiar like this example, php: remove brackets/contents from a string? i have no idea to replace

$str = \'(ABC)some text\'

into



        
4条回答
  •  别那么骄傲
    2021-01-22 05:54

    Instead of preg_replace, I would use preg_match:

    preg_match('#\(([^)]+)\)#', $str, $m);
    echo $m[1];
    

提交回复
热议问题