note 45707 added to reference.pcre.pattern.modifiers

From: Date: Wed, 15 Sep 2004 18:25:38 +0000
Subject: note 45707 added to reference.pcre.pattern.modifiers
Groups: php.notes 
Request: Send a blank email to php-notes+get-76770@lists.php.net to get a copy of this message
Please note that when it means all whitespace characters are ignored when x (PCRE_EXTENDED) modifier is set, the use of \t, \r, and \n (and some others as well) will not work outside character class and need to be escaped as \\t, \\r, or \\n. Hope this might help to clear up some confusions. Example: <?php // returns 1 (matches) preg_match("/A B C/x", "ABC"); // also returns 1 (matches) preg_match("/A \\n B \\n C/x", "ABC"); // returns 0 (does not match because in order for \\n to be captured you must escape it) preg_match("/A \\n B \\n C/x", "A\\nB\\nC"); // returns 1 (matches) preg_match("/A \\\\n B \\\\n C/x", "A\\nB\\nC"); ?> ---- Manual Page -- http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45707 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45707&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45707&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76770) next »