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

PHP preg_match matching skills for multiple languages

高洛峰
Release: 2023-03-04 17:12:02
Original
1446 people have browsed it

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;) );
Copy after login

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;) );
Copy after login

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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template