|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76376 preg_match fails to match pattern with backslash in the beginning of string.
Submitted: 2018-05-25 12:04 UTC Modified: 2018-05-25 13:17 UTC
From: alexander dot aka dot alegz at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: PCRE related
PHP Version: 7.0.30 OS: Centos 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
16 + 6 = ?
Subscribe to this entry?

 [2018-05-25 12:04 UTC] alexander dot aka dot alegz at gmail dot com
OS: CentOS7
Source repo: remi
Version: PHP 7.0.30 (built: Apr 24 2018 21:28:23) ( NTS )

Reproduced both in cli and with web-server (as apache module).

Environment is pre-configured with bitrix-env ( on LXC container.

Test script:

$a = 'abc';
var_dump(preg_match('/^a/', $a));

$a = 'a\bc';
var_dump(preg_match('/^a\\b/', $a));

$a = '\abc';
var_dump(preg_match('/^\\a/', $a));

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-25 13:17 UTC]
-Status: Open +Status: Not a bug -Package: Regexps related +Package: PCRE related -Assigned To: +Assigned To: cmb
 [2018-05-25 13:17 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

You need to escape the backslash twice, see
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed May 25 12:05:44 2022 UTC