search

Home  >  Q&A  >  body text

How to use backslash in preg_repalce()?

I checked the manual, but I don’t understand this sentence. I would like to ask for advice humbly: If you want to use backslashes in replacement, you must use 4 ("\\\\", translation annotation: because this is first of all a PHP string, After escaping, there are two, and then after passing through the regular expression engine, it is considered to be one original backslash).

  2538 days ago1221

reply all(2)I'll reply

  • 寻觅 beyond

    寻觅 beyond2018-02-02 16:17:17

    Use single quotes directly, why bother?

    reply
    0
  • 韦小宝

    韦小宝2018-01-30 09:09:03

    This is very clear. Two slashes are needed for escaping, one for regular expressions, and one for the original text

    reply
    0
  • Cancelreply