|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2017-08-13 13:07 UTC] bublik dot drdrdr at gmail dot com
 Description:
------------
preg_match finds a wrong match with these params:
pattern "(?=.*?[A-Za-z]).{8,}",
subject "вasdaв". Last contains 6 chars (english and russian), but regex pattern must accept only 8+ chars.
Test script:
---------------
$out = array();
preg_match("/(?=.*?[A-Za-z]).{8,}/", "вasdaв", $out);
var_dump($out);
Expected result:
----------------
array(0) { }
Actual result:
--------------
array(1) { [0]=> string(8) "вasdaв" }
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 02:00:02 2025 UTC | 
preg_match() is the correct function to use, you just need to specify the /u modifier if you're working with UTF-8. Please do not recommend the use of mb_ereg_match() unless it is strictly necessary. Using "/(?=.*?[A-Za-z]).{8,}/u" will produce the desired result.