Bug #76376 [Opn->Nab]: preg_match fails to match pattern with backslash in the beginning of string.

From: Date: Fri, 25 May 2018 13:17:16 +0000
Subject: Bug #76376 [Opn->Nab]: preg_match fails to match pattern with backslash in the beginning of string.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215367@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76376&edit=1 ID: 76376 Updated by: cmb@php.net Reported by: alexander dot aka dot alegz at gmail dot com Summary: preg_match fails to match pattern with backslash in the beginning of string. -Status: Open +Status: Not a bug Type: Bug -Package: Regexps related +Package: PCRE related Operating System: Centos 7 PHP Version: 7.0.30 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You need to escape the backslash twice, see <https://3v4l.org/L3vvq>. Previous Comments: ------------------------------------------------------------------------ [2018-05-25 12:04:07] alexander dot aka dot alegz at gmail dot com Description: ------------ 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 (https://training.bitrix24.com/support/training/course/index.php?COURSE_ID=113&LESSON_ID=9463&LESSON_PATH=9681.9461.9463) on LXC container. Test script: --------------- <?php $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: ---------------- int(1) int(1) int(1) Actual result: -------------- int(1) int(1) int(0) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76376&edit=1

« previous php.bugs (#215367) next »