b00ker_b0y Posted October 1, 2007 Share Posted October 1, 2007 Hey people little stuck using preg replace. Basicly i have the string looking like this: "ebook\'s" but not to sure how to remove the backslash using preg replace as a / is a delimiator. Any suggestions would be grateful! Link to comment https://forums.phpfreaks.com/topic/71355-preg-replace-help/ Share on other sites More sharing options...
HuggieBear Posted October 1, 2007 Share Posted October 1, 2007 Use two backslashes.... The first will escape the second. Regards Huggie Link to comment https://forums.phpfreaks.com/topic/71355-preg-replace-help/#findComment-359024 Share on other sites More sharing options...
b00ker_b0y Posted October 1, 2007 Author Share Posted October 1, 2007 hey, tried that! $campaign = "ebook\'s"; $campaign = preg_replace('\\','',$campaign); dont work tho Link to comment https://forums.phpfreaks.com/topic/71355-preg-replace-help/#findComment-359028 Share on other sites More sharing options...
HuggieBear Posted October 1, 2007 Share Posted October 1, 2007 You still need pattern delimeters in there... <?php $campaign = "ebook\'s"; $campaign = preg_replace('/\\/', '', $campaign); ?> More importantly though, where did the slash come from? In this instance where has ebook\'s come from? As PHP has functions for dealing with slashes. e.g stripslashes() Regards Huggie Link to comment https://forums.phpfreaks.com/topic/71355-preg-replace-help/#findComment-359031 Share on other sites More sharing options...
b00ker_b0y Posted October 1, 2007 Author Share Posted October 1, 2007 hmm, got this error with that: Warning: preg_replace() [function.preg-replace]: No ending delimiter '/' found Link to comment https://forums.phpfreaks.com/topic/71355-preg-replace-help/#findComment-359032 Share on other sites More sharing options...
HuggieBear Posted October 1, 2007 Share Posted October 1, 2007 Try this: $campaign = preg_replace("/\\/", '', $campaign); Regards Huggie Link to comment https://forums.phpfreaks.com/topic/71355-preg-replace-help/#findComment-359043 Share on other sites More sharing options...
b00ker_b0y Posted October 1, 2007 Author Share Posted October 1, 2007 nope, says same thing Link to comment https://forums.phpfreaks.com/topic/71355-preg-replace-help/#findComment-359047 Share on other sites More sharing options...
b00ker_b0y Posted October 1, 2007 Author Share Posted October 1, 2007 i gonna forget it now lol and just use strip slashes as you suggested and work things different way. cheers for your help anyhow buddy! Link to comment https://forums.phpfreaks.com/topic/71355-preg-replace-help/#findComment-359063 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.