UTF-8 characters in preg_match_all (PHP)

后端 未结 4 894
花落未央
花落未央 2020-12-17 19:34

I have preg_match_all(\'/[aäeëioöuáéíóú]/u\', $in, $out, PREG_OFFSET_CAPTURE);

If $in = \'hëllo\' $out is:

arr         


        
4条回答
  •  执念已碎
    2020-12-17 19:37

    Another way how to split UTF-8 $string by a regular expression is to use function preg_split(). Here is my working solution:

        $result = preg_split('~\[img/\d{1,}/img\]\s?~', $string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
    

    PHP 5.3.17

提交回复
热议问题