ToonMariner Posted April 18, 2006 Share Posted April 18, 2006 Been busy on here today!!!OK a quickyI want to replace "; "with ;(carriage return)that is a semi-colon and a carriage return (not the words!!!!! ;))$string = preg_replace('/; /',';\r,$string);aint working (tried \\r too)Any help much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/7737-rexex/ Share on other sites More sharing options...
shocker-z Posted April 18, 2006 Share Posted April 18, 2006 y not use str_replace??$string=str_replace(';',";\r",$string);RegardsLiam Quote Link to comment https://forums.phpfreaks.com/topic/7737-rexex/#findComment-28231 Share on other sites More sharing options...
obsidian Posted April 18, 2006 Share Posted April 18, 2006 [!--quoteo(post=366058:date=Apr 18 2006, 11:55 AM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Apr 18 2006, 11:55 AM) [snapback]366058[/snapback][/div][div class=\'quotemain\'][!--quotec--]Been busy on here today!!!OK a quickyI want to replace "; "with ;(carriage return)that is a semi-colon and a carriage return (not the words!!!!! ;))$string = preg_replace('/; /',';\r,$string);aint working (tried \\r too)Any help much appreciated[/quote]depending on what OS is running on your server, you have to have "\n" instead (*NIX servers), but just to be safe, your best bet is to use "\r\n" for all your carriage returns:[code]$String = preg_replace('|;|', ";\r\n", $String);[/code]i believe it also makes a difference that you use double quotes for the replacement so the escape characters are actually recognized. Quote Link to comment https://forums.phpfreaks.com/topic/7737-rexex/#findComment-28234 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.