本文章给大家介绍PHP中多字节字符的preg_match_all实例,大家可参考,代码如下:
- function mb_ereg_match_all($pattern, $subject, array &$subpatterns)
- {
- if(!mb_ereg_search_init($subject, $pattern))
- return false;
- $subpatterns = array();
- while($r = mb_ereg_search_regs()) {
- }
- return true;
- }
-
- $pattern = ‘[^s ]+’;
- $subject = ‘你好, 吃了么。 我吃 的包子加油条。’;
- mb_ereg_match_all($pattern, $subject, $result);
- print_r($result);
|