Skip to content
Advertisement

str_contains returns true, but preg_match returns false

I am getting the HTML code of this website –

https://theatrevazrajdane.bg/%D1%82%D0%B2%D0%BE%D1%80%D1%87%D0%B5%D1%81%D0%BA%D0%B8-%D1%81%D1%8A%D1%81%D1%82%D0%B0%D0%B2/%D0%B0%D0%BA%D1%82%D1%8C%D0%BE%D1%80%D0%B8/2

with this code $html = file_get_contents($url)

and then I am running a simple regex which does not work and I have no idea why.

This code output – FALSE

preg_match('/actor/miu', $html);

and this code output – TRUE

str_contains($html, 'actor');

Do you know where it could be the reason I checked the HTML several times. It is the correct HTML.

Advertisement

Answer

This page has problems with unicode.

Try preg_match('/actor/mi', $html);

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement