$sub= '我有5斤大米,6斤白面,售卖100元';

我想提取"有5斤大米"、"卖100元",用preg_match_all( '/.?\d+.?/', $sub, $match)出现乱码

改成preg_match_all( '/.?\d+.?/u', $sub, $match)后正常。

这里的小写字母u是修饰符,表示把字符当UTF-8处理。

官方文档:https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php

preg_match提取中文的乱码问题探索

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2021-12-31
猜你喜欢
  • 2022-01-12
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
相关资源
相似解决方案