Bug #61958 [Nab]: Trailing linebreak ignored

From: Date: Sun, 06 May 2012 06:06:21 +0000
Subject: Bug #61958 [Nab]: Trailing linebreak ignored
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-170247@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61958&edit=1 ID: 61958 User updated by: kulakov74 at yandex dot ru Reported by: kulakov74 at yandex dot ru Summary: Trailing linebreak ignored Status: Not a bug Type: Bug Package: PCRE related Operating System: Linux, Windows 7 PHP Version: 5.3.12 Block user comment: N Private report: N New Comment: Thank you. Previous Comments: ------------------------------------------------------------------------ [2012-05-06 05:07:45] rasmus@php.net This is documented behaviour and consistent with every Perl-style regex implementation in every language. Use the 'D' modifier if you want to change that behaviour. See http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php eg. echo preg_match('~^\w$~D', "a\n"); ------------------------------------------------------------------------ [2012-05-06 04:35:36] kulakov74 at yandex dot ru Sorry, the title should be "preg_match() ignores trailing linebreak" ------------------------------------------------------------------------ [2012-05-06 04:19:53] kulakov74 at yandex dot ru Description: ------------ I want to check if a string is a single wordcharacter but even it has a trailing linebreak preg_match() returns 1. Test script: --------------- echo preg_match('~^\w$~', "a\n"); Expected result: ---------------- 0 Actual result: -------------- 1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61958&edit=1

« previous php.bugs (#170247) next »