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.
我有像这样的字符串
+200% just string +20% other string +350% other etc ..
我需要一个正则表达式来删除+X%并仅获取以下字符串。我试过了
+X%
echo trim(preg_replace("/[+][0-9][%]/","",$str));
但这给出了与 相同的输出echo $str。
echo $str
你需要一个+after [0-9],意思是“一个或多个”:
+
[0-9]
preg_replace("/[+][0-9]+%/", "", $str)