Reputation: 456
I wan't to check if a string ($nick_2) got " or ñ
Is this correct? i can't make it work
if ( (strlen($nick_2) >= 3) && (strlen($nick_2) <= 25) && (!preg_match("/\"/", $nick_2)) && (!preg_match("/ñ/", strtolower($nick_2))) ) {
Upvotes: 0
Views: 295
Reputation: 97805
Possibly your string is in UTF-8, in which case, you must use the u
modifier in preg_match
and should submit your expression to that function also in UTF-8.
If that's the case, you will also want to do some of these things:
strtolower
and strlen
with mb_
alternatives.Upvotes: 1
Reputation: 360572
For finding single characters, regexes are massive overkill. Just use
if ((strpos('"', $nick_2) !== FALSE) || (strpos('ñ', $nick_2) !== FALSE)) {
... chars were found
}
Upvotes: 2