|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-02-25 10:33 UTC] rasmus@php.net
-Status: Open
+Status: Bogus
[2011-02-25 10:33 UTC] rasmus@php.net
[2011-02-25 10:43 UTC] jeroen at asystance dot nl
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 01:00:01 2025 UTC |
Description: ------------ The perl-compatible regex matcher somehow matches a negated character class if the string to match contains the same characters, and in the same order, as the character class. I don't see why /[^ab]/ should match "ab" but not "ba". Perl agrees: $ perl -e 'for("ab","ba") { print "$_: "; if( /[^ab]/ ) {print "match\n"} else {print "no match\n"}}' ab: no match ba: no match Test script: --------------- <?php echo "expecting 0, 0, 0, 0, 0\n"; echo preg_match( '[^ab]', 'ba' ) . "\n"; // expected no match, passes echo preg_match( '[^ab]', 'ab' ) . "\n"; // expected no match, fails echo preg_match( '([^ab])', 'ab' ) . "\n"; // expected no match, passes echo preg_match( '[^ab]', 'aba' ) . "\n"; // expected no match, fails echo preg_match( '[^ab]', 'abb' ) . "\n"; // expected no match, fails echo preg_match( '([^ab])', 'abb' ) . "\n"; // expected no match, passes ?> Expected result: ---------------- expecting 0, 0, 0, 0, 0, 0 0 0 0 0 0 0 Actual result: -------------- expecting 0, 0, 0, 0, 0, 0 0 1 0 1 1 0