note 115614 added to function.preg-match

From: Date: Tue, 26 Aug 2014 15:35:13 +0000
Subject: note 115614 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-200314@lists.php.net to get a copy of this message
I noted that PCRE_ANCHORED (the pattern modifier A) does work fine if using an offset. If you use the escape sequence \A or even the dash "^" in the regex, it does not work (even if in multiline mode)... <?php $text = 'foo bar'; print (int) preg_match('/^bar/',$text,$a,null,4); // prints 0 print (int) preg_match('/\Abar/',$text,$a,null,4); // prints 0 print (int) preg_match('/bar/A',$text,$a,null,4); // prints 1 ?> Hope this helps someone out there! :-) Version: PHP 5.5.12 ---- Server IP: 72.52.91.14 Probable Submitter: 92.79.134.250 ---- Manual Page -- http://php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/115614 Del: integrated -- https://master.php.net/note/delete/115614/integrated Del: useless -- https://master.php.net/note/delete/115614/useless Del: bad code -- https://master.php.net/note/delete/115614/bad+code Del: spam -- https://master.php.net/note/delete/115614/spam Del: non-english -- https://master.php.net/note/delete/115614/non-english Del: in docs -- https://master.php.net/note/delete/115614/in+docs Del: other reasons-- https://master.php.net/note/delete/115614 Reject -- https://master.php.net/note/reject/115614 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200314) next »