wolves Posted April 12, 2006 Share Posted April 12, 2006 how to replace, [b]\\[/b] to [b]\[/b] and [b]\[/b] to [b]nothing[/b] using preg_replace?if someone knows a tutorial of regular expresions.. tell me...tks Link to comment https://forums.phpfreaks.com/topic/7196-preg_replace/ Share on other sites More sharing options...
ToonMariner Posted April 12, 2006 Share Posted April 12, 2006 try this...[code]<?php$lookfor = array('/\\\\/','/\\/');$repwith = array('\\','');$string = preg_replace($lookfor,$repwith,$string);?>[/code]where $string is the string you want to do the replacement on. Link to comment https://forums.phpfreaks.com/topic/7196-preg_replace/#findComment-26185 Share on other sites More sharing options...
obsidian Posted April 12, 2006 Share Posted April 12, 2006 [!--quoteo(post=363994:date=Apr 12 2006, 08:00 AM:name=wolves)--][div class=\'quotetop\']QUOTE(wolves @ Apr 12 2006, 08:00 AM) [snapback]363994[/snapback][/div][div class=\'quotemain\'][!--quotec--]how to replace, [b]\\[/b] to [b]\[/b] and [b]\[/b] to [b]nothing[/b] using preg_replace?if someone knows a tutorial of regular expresions.. tell me...tks[/quote][a href=\"http://www.regular-expressions.info\" target=\"_blank\"]http://www.regular-expressions.info[/a]also, if that's what you're after, why not just use stripslashes()? Link to comment https://forums.phpfreaks.com/topic/7196-preg_replace/#findComment-26186 Share on other sites More sharing options...
wolves Posted April 12, 2006 Author Share Posted April 12, 2006 [!--quoteo(post=363999:date=Apr 12 2006, 07:17 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Apr 12 2006, 07:17 AM) [snapback]363999[/snapback][/div][div class=\'quotemain\'][!--quotec--]also, if that's what you're after, why not just use stripslashes()?[/quote]yeah, it's make my life easier.. I thought that it will strip all \, but nottks, all! Link to comment https://forums.phpfreaks.com/topic/7196-preg_replace/#findComment-26188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.