Destramic Posted July 17, 2014 Share Posted July 17, 2014 hey guys im after the pattern to replace , and & symbols please?...any help would be great thank you Quote Link to comment https://forums.phpfreaks.com/topic/289961-regex/ Share on other sites More sharing options...
requinix Posted July 17, 2014 Share Posted July 17, 2014 What have you tried so far? Quote Link to comment https://forums.phpfreaks.com/topic/289961-regex/#findComment-1485593 Share on other sites More sharing options...
.josh Posted July 17, 2014 Share Posted July 17, 2014 Replace them with what? Also, you probably only really need to use str_replace not regex. Quote Link to comment https://forums.phpfreaks.com/topic/289961-regex/#findComment-1485594 Share on other sites More sharing options...
Destramic Posted July 17, 2014 Author Share Posted July 17, 2014 str_replace("?,","", $var); I want to replace it with nothing...just want to remove any one of the matching characters...but I'm unaware of the regex syntax I need thank you Quote Link to comment https://forums.phpfreaks.com/topic/289961-regex/#findComment-1485602 Share on other sites More sharing options...
.josh Posted July 17, 2014 Share Posted July 17, 2014 str_replace matches for exactly what you specify, no patterns (no regex). The first argument of str_replace can either be a string or an array. This is fine, because you aren't trying to match for any patterns. $var = str_replace(array(',','&'),'',$var); Quote Link to comment https://forums.phpfreaks.com/topic/289961-regex/#findComment-1485608 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.