Could anyone explain to me why this is returning TRUE
? There are 7 z's yet it should be returning FALSE
because I've set a max limit of 6 in the regex.
preg_match('/z{4,6}/', "zzzzzzz")
That is because your string includes a substring of 4 to 6 'z's. If you want the match to be against your whole string, you have to put in the anchors in your regex.
/^z{4,6}$/
or
/\Az{4,6}\z/