Reputation: 616
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));
Upvotes: 1
Views: 227
Reputation: 30995
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));
Upvotes: 2