|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-12-24 13:34 UTC] cataphract@php.net
-Status: Open
+Status: Bogus
[2011-12-24 13:34 UTC] cataphract@php.net
[2011-12-25 16:28 UTC] post at kira-bianca dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 09 14:00:01 2025 UTC |
Description: ------------ Hi! My HTML source I write in the encoding UTF-8 and I have probably found a bug (... soon cost me two hours of searching and working for a flaw in my logic). And indeed, I want with preg_match() a string to check for valid characters and simultaneously for a minimum length. In the string should german special characters (Ä, Ö, Ü, ß) also be allowed. As I noted, these are all PCRE functions treated as two letters, if the encoding is UTF-8. Examples see below. For tips on how I can work around this problem, I would be grateful. greeting Ki-Bi Test script: --------------- /* remark: The source is saved with encoding UTF-8 (without BOM) */ $animal = 'Bär'; if (preg_match('~^[a-zäöüß\.\- ]{4,26}$~i', $animal)){ echo "$animal has a word length from 4 to 26 letters.\n"; }else{ echo "$animal is too short or too long!\n";} $string = 'Dörte hütet die Schäfchen und trinkt dabei ein Maß Bier. Ärger gibt es dabei nicht.'; echo preg_replace('~[äöüß]~i', '*', $string); Expected result: ---------------- Bär has a word length from 4 to 26 letters. D**rte h**tet die Sch**fchen und trinkt dabei ein Ma** Bier. *�rger gibt es dabei nicht.