0
<?php
$foo='تذوق لحظات الطعام والشراب اللذيذة';
var_dump(preg_match('/\R/', $foo));
var_dump(str_contains($foo, "\r"));
?>

the output of the above is that the preg_match returns 1 indicating a match but the str_contains returns false (as I'd expect since I see no carriage return?).

Is this some issue relating to performing regex searches on non-ASCII strings?

You can demo this here

callum
  • 57
  • 6
  • 2
    Does this answer your question? [PHP Regex: How to match \r and \n without using \[\r\n\]?](https://stackoverflow.com/questions/18988536/php-regex-how-to-match-r-and-n-without-using-r-n). See the `u` modifier in [this answer](https://stackoverflow.com/a/18992691/2257664). Here is the result: https://onlinephp.io/c/3031e – A.L Jul 28 '23 at 14:08
  • Your string contains the byte `\x85` that is the NEL (Next Line) character in ASCII. `\R` matches this character too. If you switch to utf-8 mode with the u modifier, `\R` will match `\xc2\x85` for the NEL character. Whatever, your string doesn't contain a carriage return. – Casimir et Hippolyte Jul 28 '23 at 17:03

0 Answers0