I have string "h///e/ll\\o\//\"
.
Need to remove all slashes from it back and forth slashes multiple times can someone show me regex to do this?
its for php preg_replace();
Try this:
var_dump(preg_replace("@[/\\\]@", "", "h///e/ll\\o\\//\\"));
// Output: string(5) "hello"
http://codepad.org/PIjKsc9F
Or alternativly
var_dump(str_replace(array('\\', '/'), '', 'h///e/ll\\o\\//\\'));
// Output: string(5) "hello"
http://codepad.org/0d5j9Mmm
You don't need a regex to remove these:
$string = str_replace(array('/', '\\'), '', $string);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With