mtylerb Posted November 5, 2008 Share Posted November 5, 2008 I'm trying to match and replace any "?" and "/" characters as well as anything after and including the "." in a URL, this would match the ending part, right? <?php $areaSlug = preg_replace('/^(\.)\w*(ht)+(\w)*/', '',$topSlug[1]); ?> Can I do this to also match the question mark and slash: <?php $areaSlug = preg_replace('/(^(\.)\w*(ht)+(\w)*)(\?)+(\/)+/', '',$topSlug[1]); ?> Quote Link to comment https://forums.phpfreaks.com/topic/131482-solved-quick-question/ Share on other sites More sharing options...
mtylerb Posted November 5, 2008 Author Share Posted November 5, 2008 Nevermind, I solved the problem with: <?php $replace = array('/(\.)\w*(ht)+(\w)*/','/\?+/','/\/+/'); $counted = count($topSlug); $areaSlug = preg_replace($replace, '',$topSlug[($counted-1)]); ?> Thanks anyway. Quote Link to comment https://forums.phpfreaks.com/topic/131482-solved-quick-question/#findComment-682858 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.