note 125720 rejected from regexp.reference.back-references by cmb
| From: | cmb@php.net | Date: | Mon, 25 Jan 2021 11:16:05 +0000 |
| Subject: | note 125720 rejected from regexp.reference.back-references by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216229@lists.php.net to get a copy of this message | ||
Note Submitter: emosewaj at gmx dot de
----
Mind that back references only work in single-quoted strings. In double quoted strings, they will be
parsed as the octal notation of a character.
<?php
preg_match("/^(a)(?!\1)/", "aa");
// true, that's not what we want!
// Notice the only difference being the single quotes.
preg_match('/^(a)(?!\1)/', "aa");
// false
?>