[英]How to add hindi character search in preg_match_all() in php?
We can know it is for English characters like,我们可以知道它是针对英文字符的,例如,
if( preg_match_all('/something/', $any, $match) if( preg_match_all('/something/', $any, $match)
But can we also use for hindi character??但是我们也可以用于印地文字符吗??
I have used it in my code itself我已经在我的代码中使用了它
/[^\p{Zs}\p{P}]*?ह[^\p{Zs}\p{P}]*/u
Modifier /u
is for unicode support.修饰符/u
用于 unicode 支持。
for your code do it like this对于您的代码,请这样做
$any = 'तरह के लाभ मिलते हैं';
$searchword = 'ह';
preg_match_all('/[^\p{Zs}\p{P}]*?'.$searchword.'[^\p{Zs}\p{P}]*/u', $any, $match);
print_r($match);
output will be :输出将是:
Array
(
[0] => Array
(
[0] => तरह
[1] => हैं
)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.