i want to find an exact word has been a string. but if its end of the string, word boundaries failing. i thought because of special turkish chars but second code works expected. where is my mistake?
this code returns 0
$row = "TEDARİKÇİ,MÜŞTERİ";
var_dump( preg_match('#\bMÜŞTERİ\b#iu', $row));
but this one returns 1
$row = "TEDARİKÇİ,MÜŞTERİ";
var_dump( preg_match('#\bMÜŞTERİ$#iu', $row));
I though both regex should work but I got same problem as you in regex101. So, in order to fix this you can change your regex to:
$row = "TEDARİKÇİ,MÜŞTERİ";
var_dump( preg_match('#\bMÜŞTERİ(\b|$)#iu', $row));
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.