Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中的preg_match_all()中添加印地语字符搜索?_Php_Regex_Preg Match All - Fatal编程技术网

如何在php中的preg_match_all()中添加印地语字符搜索?

如何在php中的preg_match_all()中添加印地语字符搜索?,php,regex,preg-match-all,Php,Regex,Preg Match All,我们可以知道它是为像 if(preg_match_all(“/something/”,$any,$match) 但是我们也可以使用印地语字符吗?我已经在代码中使用了它 /[^\p{Zs}\p{P}]*?ह[^\p{Zs}\p{P}]*/u 修饰符/u用于unicode支持 对于您的代码如下所示 $any = 'तरह के लाभ मिलते हैं'; $searchword = 'ह'; preg_match_all('/[^\p{Zs}\p{P}]*?'.$searchword.'[

我们可以知道它是为像

if(preg_match_all(“/something/”,$any,$match)


但是我们也可以使用印地语字符吗?

我已经在代码中使用了它

/[^\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] => हैं
        )

)

如果我需要英语和印地语两种语言字符,如“英语字符,印地语字符”,在这种情况下,我如何执行正则表达式??