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] ras...@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