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
「1つ以上」を意味する+afterが必要です。[0-9]
+
[0-9]
preg_replace("/[+][0-9]+%/", "", $str)