doukuiqian5345 2012-11-05 14:17
浏览 28

preg_replace regex for(123):

I'm looking for a preg_replace regex that will match and remove

(123):

and

(+12):

I've tried a few including

$str = preg_replace('/([0-9]+)/s', '', $str);

but none I've tried have removed the () brackets/parentheses nor the + sign

(yes I realise the + in the regex means plus/continue not an actual + sign) ;)

  • 写回答

1条回答 默认 最新

  • douying2243 2012-11-05 14:19
    关注

    You need to escape the parenthesis and add the + sign to your character group:

    $str = preg_replace('/\([+0-9]+\)/s', '', $str);
    
    评论

报告相同问题?