Jump to content

Archived

This topic is now archived and is closed to further replies.

wolves

preg_replace

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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()?

Share this post


Link to post
Share on other sites
[!--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 not

tks, all!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.