1

我的字符串是外语的。我使用以下正则表达式:

$str = 'մի քանի Բառ ձեր մասին';
$word = 'բառ';

$cont = preg_match_all("/.{0,80}[^\s]*?".preg_quote($word)."[^\s]*?.{0,80}/si",$str,$matched);
print_r($matched);//returns Array ( [0] => Array ( ) ) ..

.

...但如果我设置:

$word = "Բառ";//returns Array ( [0] => Array ( [0] => մի քանի Բառ ձեր մասին ) )  

我该怎么做才能在外语中使用 I 修饰符?

4

1 回答 1

5

尝试添加u修饰符:

$cont = preg_match_all("/.{0,80}[^\s]*?".preg_quote($word)."[^\s]*?.{0,80}/siu",$str,$matched);
于 2010-08-24T09:51:02.327 回答