I’m totally useless at regex, any advice much appreciated.
$url = 'http://somedomain.com?var=<##var##>&var2=<##var2##>';
echo preg_replace('^<##(.*)##>$', '', $url);
Trying to strip anything between (and including) <## and ##>. So my result would be:
http://somedomain.com?var=&var2=
Thanks
The code should be:
The
^and$you used are wrong, they represend the begin or the end of the string and you won’t replace only the<##...##>part if<##is at the beginning and##>at the end of the string.Also the
?after.*means that it matches everything from the<##until the next##>. If you use.*it matches everything from the first<##until the last##>so you result would behttp://somedomain.com?var=