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))) ) {
For finding single characters, regexes are massive overkill. Just use
if ((strpos('"', $nick_2) !== FALSE) || (strpos('ñ', $nick_2) !== FALSE)) {
... chars were found
}
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.