Home >Backend Development >PHP Tutorial >PHP preg_match matching skills for multiple languages

PHP preg_match matching skills for multiple languages

高洛峰
高洛峰Original
2017-01-09 10:09:401451browse

Regular: [\S]{2,32}

PHP preg match 多国语言

Filtering works
In PHP:

<?php
var_dump( preg_match("/[\S\b]{2,32}/",&#39;ج&#39;) );
echo &#39;<hr />&#39;;
var_dump( preg_match("/[\S\b]{2,32}/",&#39;中国&#39;) );

doesn’t work

You need to add a parameter u, read the code according to uniode

<?php
var_dump( preg_match("/[\S\b]{2,32}/u",&#39;ج&#39;) );
echo &#39;<hr />&#39;;
var_dump( preg_match("/[\S\b]{2,32}/u",&#39;中国&#39;) );
echo &#39;<hr />&#39;;
var_dump( preg_match("/[\S\b]{2,32}/u",&#39;Дракон&#39;) );
echo &#39;<hr />&#39;;
var_dump( preg_match("/[\S\b]{2,32}/u",&#39;cc&#39;) );

For more PHP preg_match matching skills in multiple languages, please pay attention to the PHP Chinese website!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn