PHP preg_replace \ [英] PHP preg_replace \

查看:76
本文介绍了PHP preg_replace \的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个非常简单的问题:我如何preg_replace反斜杠字符?

Really simple question: how can I preg_replace the backslash character?

推荐答案

是的,但是您需要对其进行转义.在正则表达式中使用它时,请使用\\来代替它,请使用\\\\(它将变成\\,将被解释为单个反斜杠).

Yes, but you need to escape it. When using it in the regexp use \\ to use it in the replacement, use \\\\ (that will turn into \\ that will be interpreted as a single backslash).

这篇关于PHP preg_replace \的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆