DrTrans Posted October 18, 2009 Share Posted October 18, 2009 Basically what i need to do is $title = "This Suck's" $striped = ereg_replace("[^A-Za-z0-9]", " ", $title ); However, I only want it to strip the " ' " (Apostrophe) not all the characters. just Apostraphe's.. Can someone help please. Quote Link to comment https://forums.phpfreaks.com/topic/178076-solved-ereg_replace/ Share on other sites More sharing options...
Maq Posted October 18, 2009 Share Posted October 18, 2009 1) If you look in the manual: This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged. 2) Patterns require delimiters (~, or any non-reserved keyword in regex. 3) You were missing a semi-colon after the $title declaration. 4) Instead of blacklisting, just explicitly put in apostraphy. 5) Use code tags. 6) I think you meant to say, "stripped" not "striped". $title = "This Suck's"; $stripped = preg_replace("~'~", " ", $title ); echo $stripped; ?> Quote Link to comment https://forums.phpfreaks.com/topic/178076-solved-ereg_replace/#findComment-938946 Share on other sites More sharing options...
.josh Posted October 18, 2009 Share Posted October 18, 2009 actually if you are just looking to only replace a single quote, use str_replace Quote Link to comment https://forums.phpfreaks.com/topic/178076-solved-ereg_replace/#findComment-939025 Share on other sites More sharing options...
Maq Posted October 18, 2009 Share Posted October 18, 2009 actually if you are just looking to only replace a single quote, use str_replace Good point. Quote Link to comment https://forums.phpfreaks.com/topic/178076-solved-ereg_replace/#findComment-939027 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.