DeanWhitehouse Posted February 23, 2012 Share Posted February 23, 2012 Hello all, I'm trying to generate a regex that will remove UTM parameters from my refferrer URLs. <?php //"test" parameter is lost echo preg_replace("/&?utm_(.*)\=[^&]+/","","?utm_source=bottom&utm_medium=widget&test&test&utm_campaign=testcamp"); ?> The regex works on removing the paremeters whilst keeping parameters before and after in tact. However parameters in-between are lost. Any ideas would be great. I'm testing the above code on http://writecodeonline.com/php/ Link to comment https://forums.phpfreaks.com/topic/257622-remove-utm-tags-from-url-regex/ Share on other sites More sharing options...
ManiacDan Posted February 23, 2012 Share Posted February 23, 2012 So close. echo preg_replace("/&?utm_(.*?)\=[^&]+/","","?utm_source=bottom&utm_medium=widget&test&test&utm_campaign=testcamp"); Link to comment https://forums.phpfreaks.com/topic/257622-remove-utm-tags-from-url-regex/#findComment-1320422 Share on other sites More sharing options...
DeanWhitehouse Posted February 23, 2012 Author Share Posted February 23, 2012 aha thank you, I'm a bit of a newbie to regex Link to comment https://forums.phpfreaks.com/topic/257622-remove-utm-tags-from-url-regex/#findComment-1320428 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.