我有字符串 "h///e/ll\\o\//\"
。
需要多次删除所有斜线来回斜线有人可以告诉我正则表达式来做这个吗?
它用于 php preg_replace();
最佳答案
试试这个:
var_dump(preg_replace("@[/\\\]@", "", "h///e/ll\\o\\//\\"));
// Output: string(5) "hello"
或者交替
var_dump(str_replace(array('\\', '/'), '', 'h///e/ll\\o\\//\\'));
// Output: string(5) "hello"
关于php - 删除所有斜杠正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9285704/