|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-04-16 09:14 UTC] f dot sowade at r9e dot de
Description:
------------
The intl extension reports the Unicode ellipsis character (U+2026) to be a punctuation. PCRE matches the ellipsis when matching letters but not when matching punctuation. So the character class for the ellipsis differs between the intl extension and PCRE. I think that intl is correct here and the character class should be punctuation. But both extensions should at least agree on the same character class.
Test script:
---------------
var_dump(IntlChar::ispunct("\u{2026}")); // true
var_dump(IntlChar::isalpha("\u{2026}")); // false
var_dump(preg_match('/\\p{Z}/', "\u{2026}")); // 0 (but would expect 1)
var_dump(preg_match('/\\p{L}/', "\u{2026}")); // 1 (but would expect 0)
Expected result:
----------------
bool(true)
bool(false)
int(1)
int(0)
Actual result:
--------------
bool(true)
bool(false)
int(0)
int(1)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 22:00:01 2025 UTC |
Sorry - the Test script should have had a P instead of a Z: var_dump(IntlChar::ispunct("\u{2026}")); // true var_dump(IntlChar::isalpha("\u{2026}")); // false var_dump(preg_match('/\\p{P}/', "\u{2026}")); // 0 (but would expect 1) var_dump(preg_match('/\\p{L}/', "\u{2026}")); // 1 (but would expect 0)You are missing the /u modifier and seem to have confused \p{P} with \p{Z}. The correct code is: var_dump(preg_match('/\\p{P}/u', "\u{2026}")); // 1 var_dump(preg_match('/\\p{L}/u', "\u{2026}")); // 0