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? Quote 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'); Quote Link to comment https://forums.phpfreaks.com/topic/131176-every-sign-only-once/#findComment-681057 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.