【发布时间】:2020-03-22 18:24:38
【问题描述】:
我们可以知道它是针对英文字符的,例如,
if( preg_match_all('/something/', $any, $match)
但是我们也可以用于印地语字符吗??
【问题讨论】:
标签: php regex preg-match-all
我们可以知道它是针对英文字符的,例如,
if( preg_match_all('/something/', $any, $match)
但是我们也可以用于印地语字符吗??
【问题讨论】:
标签: php regex preg-match-all
我已经在我的代码中使用了它
/[^\p{Zs}\p{P}]*?ह[^\p{Zs}\p{P}]*/u
修饰符 /u 用于支持 unicode。
对于你的代码这样做
$any = 'तरह के लाभ मिलते हैं';
$searchword = 'ह';
preg_match_all('/[^\p{Zs}\p{P}]*?'.$searchword.'[^\p{Zs}\p{P}]*/u', $any, $match);
print_r($match);
输出将是:
Array
(
[0] => Array
(
[0] => तरह
[1] => हैं
)
)
【讨论】: