Lumio Posted November 3, 2008 Share Posted November 3, 2008 Hello! I have some signs here: ygabodfe And I want to check a string, if it has at least 5 of this chars and every char has to be there only once. Is that possible with Regex? Link to comment https://forums.phpfreaks.com/topic/131176-every-sign-only-once/ Share on other sites More sharing options...
ddrudik Posted November 3, 2008 Share Posted November 3, 2008 function checkval($letters,$val){ return preg_match('/(?=^['.preg_quote($letters,'/').']{5,}$)(?!.*(.).*\1)/',$val) ? "pass" : "fail"; } echo checkval('ygabodfe','yodeag'); echo '<br>'.checkval('ygabodfe','yadea'); echo '<br>'.checkval('ygabodfe','yodeq'); Link to comment https://forums.phpfreaks.com/topic/131176-every-sign-only-once/#findComment-681057 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.