Ofro04 Posted April 19, 2010 Share Posted April 19, 2010 Hey. I'm looking for a simple regex to replace a url with a dynamic key at the end. ei. xxx.com?key=343fss4 I want to match and replace this string Quote Link to comment https://forums.phpfreaks.com/topic/199028-regex-to-replace-the-query-string/ Share on other sites More sharing options...
premiso Posted April 19, 2010 Share Posted April 19, 2010 $string = "\nTesting Url ei.xxx.com?key=asd234asdf234 ok to see how it replaces.\n"; $string = preg_replace('~ei.xxx.com\?key=[a-z0-9]+~i', '_replaced_ ', $string); echo $string; Quote Link to comment https://forums.phpfreaks.com/topic/199028-regex-to-replace-the-query-string/#findComment-1044696 Share on other sites More sharing options...
Ken2k7 Posted April 20, 2010 Share Posted April 20, 2010 Maybe not in that case, but shouldn't you escape the dots anyways? Quote Link to comment https://forums.phpfreaks.com/topic/199028-regex-to-replace-the-query-string/#findComment-1044981 Share on other sites More sharing options...
premiso Posted April 20, 2010 Share Posted April 20, 2010 Maybe not in that case, but shouldn't you escape the dots anyways? It would probably be better to do so. Minor over-sight of mine, thanks for pointing it out. Quote Link to comment https://forums.phpfreaks.com/topic/199028-regex-to-replace-the-query-string/#findComment-1045031 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.