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 should use regex?
views:
62answers:
3
+2
A:
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);
Boldewyn
2010-03-11 14:20:25
`\n` is a new line. `\d` are numbers.
Boldewyn
2010-03-11 14:21:46
...which is easy to remember if you stop thinking of _numbers_ but instead think of it as _digits_
dbemerlin
2010-03-11 14:25:34