Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个文本字符串:
$str = "This is my string (something else)";
该字符串在 ( ) 中可能有也可能没有,但如果有,我需要将其完全剥离。我试过这个:
$new = str_replace('/\\(.*/', '', $str);
但它似乎不起作用......我错过了什么?
$new = preg_replace('/\(.*\)/', '', $str);