search
Homephp教程php手册如何用正则表达式来表

如何用正则表达式来表

Jun 13, 2016 am 09:54 AM
asciioneDownChineseto useregularofcodescopesurfaceexpression

由于中文的ASCII码是有一定的范围的。所以你可以用下面的正则表达式来表示中文。
/^[chr(0xa1)-chr(0xff)]+$/
下面是一个使用的例子:
$str = "超越PHP";
if  (preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/", $str)) {
      echo "这是一个纯中文字符串";
} else {
      echo "这不是一个纯中文字串";
}

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.