Home php教程 php手册 详解两个PHP正则表达式特殊字符

详解两个PHP正则表达式特殊字符

Jun 13, 2016 am 11:03 AM
php specific Woolen cloth and character what is regular of expression Detailed explanation

PHP正则表达式特殊字符"[ ]"和"",那么他们是什么呢?具体的操作是什么呢?之所以他们是特殊字符,那么有什么在使用过程中特别的地方么?来让我们看看具体的介绍。

还有两个很重要的特殊字符就是"[ ]"。他们可以匹配"[]"之中出现过的字符,比如"/[az]/"可以匹配单个字符"a"或者"z";如果把上面的表达式改成这样"/[a-z]/",就可以匹配任何单个小写字母,比如"a"、"b"等等。

关于PHP正则表达式特殊字符"[ ]":

如果在"[]"中出现了"^",代表本表达式不匹配"[]"内出现的字符,比如"/[^a-z]/"不匹配任何小写字母!并且正则表达式给出了几种"[]"的默认值:

◆[:alpha:]:匹配任何字母

◆[:alnum:]:匹配任何字母和数字

◆[:digit:]:匹配任何数字

◆[:space:]:匹配空格符

◆[:upper:]:匹配任何大写字母

◆[:lower:]:匹配任何小写字母

◆[:punct:]:匹配任何标点符号

◆[:xdigit:]:匹配任何16进制数字

关于PHP正则表达式特殊字符"":

下面这些特殊字符在转义符号""转义后代表的含义如下:

◆s:匹配单个的空格符

◆S:用于匹配除单个空格符之外的所有字符。

◆d:用于匹配从0到9的数字,相当于"/[0-9]/"。

◆w:用于匹配字母,数字或下划线字符,相当于"/[a-zA-Z0-9_]/"。

◆W:用于匹配所有与w不匹配的字符,相当于"/[^a-zA-Z0-9_]/"。

◆D:用于匹配任何非10进制的数字字符。

.◆:用于匹配除换行符之外的所有字符,如果经过修饰符"s"的修饰,"."可以代表任意字符。

关于PHP正则表达式特殊字符的介绍就向你介绍到这里,希望那个对你了解和掌握PHP正则表达式特殊字符的使用有所帮助。


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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles