How can I replace a string containing a lot of ?myuser=12122
?myuser=5457
...
with empty string so that it doesn't show ?myuser=number
inside the string?
I think I开发者_StackOverflow should use regex?
yes,
preg_replace('~\?myuser=\d+~', '', $string);
The question mark is a special character in regular expressions, so you must quote it. Apart from that, it's quite straight forward:
$result = preg_replace('/\?myuser=[0-9]+/', '', $source);
$str = preg_replace("/\?myuser=(\d+)/iU","",$yourstring);
精彩评论