Home php教程 php手册 Pattern Modifiers

Pattern Modifiers

Jun 13, 2016 am 10:21 AM
pattern of expression rule

Pattern Modifiers - 规则表达式的修饰符

下面是当前规则表达式里可用的修饰. 括号内的名字是那些修饰符的内部 PCRE 名字.

i (PCRE_CASELESS)
如果设置了这个修饰符, 则表达式不区分大小写.

m (PCRE_MULTILINE)
默认的, PCRE 认为目标字符串值是单行字符串 (即使他确实包含多行). 行开始标记 (^) 只匹配字符串的开始部分, 而行结束标记 ($) 只匹配字符串的尾部,或者一个结束行(除非指定 E 修饰符). 这个和 Perl 里面一样.

如果设定了这个修饰符, 行开始和行结束结构分别匹配在目标字符串任何新行的当前位置后面的或者以前的, 和每一个开始和结束一样. 这个等于 Perl 里面的 /m 修饰符. 如果目标字符串没有 "n" 字符, 或者模式里没有 ^ 或 $ ,这个修饰符不起作用.

s (PCRE_DOTALL)
如果设置这个修饰符, 模式里的一个"点"将匹配所有字符, 包括换行. 没有他, 换行将被排除在外. 这个修饰符等同于 Perl 里面的 /s 修饰符. 一个相反的类型,例如 [^a] 将总是匹配换行字符,而不管这个修饰符的限制.

x (PCRE_EXTENDED)
如果设置这个修饰符, 模式里面的空格数句将会被全部忽略,除非用转义符或者一个字符的内部类型,还有所有字符类型外的未转义的 # 号之间的也被忽略. 这个等同于 Perl 里面的 /x 修饰符, 这样可以复杂的模式里面加入注释. 注意,只适用于数据字符. 空格字符将不会在指定的模式字符指定顺序中出现。

e
如果设置这个修饰符, preg_replace() 将在替换值里进行正常的涉及到 的替换, 等同于在 PHP 代码里面一样, 然后用于替换搜索到的字符串.

只在 preg_replace() 里使用这个修饰符; 其它 PCRE 函数忽略他.

A (PCRE_ANCHORED)
如果设置这个修饰符, 模式被强制为锚(anchored), 也就是说, 他将值匹配搜索字符串的开始. 这个效果可以通过恰当的模式结构自身来实现,那是在 Perl 里面的唯一途径.

D (PCRE_DOLLAR_ENDONLY)
如果设置这个修饰符,则模式里的 $ 修饰符将仅匹配目标字符串里的尾部. 没有这个修饰符, $ 字符也匹配新行的尾部 (但是不再新行的前面). 如果设置了 m 修饰符则忽略这个修饰符. 在 Perl 里面没有类似的.

S
如果一个模式将被使用多次, 使用长些时间分析他来来提高匹配的速度. 如果使用这个修饰符,则进行额外的分析. 目前, 研究模式仅用于非锚模式,没有一个固定的开始字符.

U (PCRE_UNGREEDY)
这个修饰符翻转数量的 "greediness" ,使得默认不被 greedy,但是如果你紧跟问号(?),则可以 greedy. 这个和 Perl 不兼容. 这个也可以通过在模式里面的(?U) 修饰符得到.

X (PCRE_EXTRA)
这个修饰符打开额外的功能,这些和 Perl 不兼容. 任何模式里面的后面带字符但没有特殊意义的反斜杠将引起错误, 从而储备这些联合用于将来的扩充. 默认的, 在 Perl 里面, 反斜杠后面有无意义的字符被当成正常的 literal. 目前还没有其他的控制特征




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

Video Face Swap

Video Face Swap

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

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)

How to set up the keyboard boot function on a GIGABYTE motherboard (enable keyboard boot mode on GIGABYTE motherboard) How to set up the keyboard boot function on a GIGABYTE motherboard (enable keyboard boot mode on GIGABYTE motherboard) Dec 31, 2023 pm 05:15 PM

How to set up keyboard startup on Gigabyte's motherboard. First, if it needs to support keyboard startup, it must be a PS2 keyboard! ! The setting steps are as follows: Step 1: Press Del or F2 to enter the BIOS after booting, and go to the Advanced (Advanced) mode of the BIOS. Ordinary motherboards enter the EZ (Easy) mode of the motherboard by default. You need to press F7 to switch to the Advanced mode. ROG series motherboards enter the BIOS by default. Advanced mode (we use Simplified Chinese to demonstrate) Step 2: Select to - [Advanced] - [Advanced Power Management (APM)] Step 3: Find the option [Wake up by PS2 keyboard] Step 4: This option The default is Disabled. After pulling down, you can see three different setting options, namely press [space bar] to turn on the computer, press group

The first choice for CS players: recommended computer configuration The first choice for CS players: recommended computer configuration Jan 02, 2024 pm 04:26 PM

1. Processor When choosing a computer configuration, the processor is one of the most important components. For playing games like CS, the performance of the processor directly affects the smoothness and response speed of the game. It is recommended to choose Intel Core i5 or i7 series processors because they have powerful multi-core processing capabilities and high frequencies, and can easily cope with the high requirements of CS. 2. Graphics card Graphics card is one of the important factors in game performance. For shooting games such as CS, the performance of the graphics card directly affects the clarity and smoothness of the game screen. It is recommended to choose NVIDIA GeForce GTX series or AMD Radeon RX series graphics cards. They have excellent graphics processing capabilities and high frame rate output, and can provide a better gaming experience. 3. Memory power

Digital audio output interface on the motherboard-SPDIF OUT Digital audio output interface on the motherboard-SPDIF OUT Jan 14, 2024 pm 04:42 PM

SPDIFOUT connection line sequence on the motherboard. Recently, I encountered a problem regarding the wiring sequence of the wires. I checked online. Some information says that 1, 2, and 4 correspond to out, +5V, and ground; while other information says that 1, 2, and 4 correspond to out, ground, and +5V. The best way is to check your motherboard manual. If you can't find the manual, you can use a multimeter to measure it. Find the ground first, then you can determine the order of the rest of the wiring. How to connect motherboard VDG wiring When connecting the VDG wiring of the motherboard, you need to plug one end of the VGA cable into the VGA interface of the monitor and the other end into the VGA interface of the computer's graphics card. Please be careful not to plug it into the motherboard's VGA port. Once connected, you can

Glodon Software's computer configuration recommendations; Glodon Software's computer configuration requirements Glodon Software's computer configuration recommendations; Glodon Software's computer configuration requirements Jan 01, 2024 pm 12:52 PM

Glodon Software is a software company focusing on the field of building informatization. Its products are widely used in all aspects of architectural design, construction, and operation. Due to the complex functions and large data volume of Glodon software, it requires high computer configuration. This article will elaborate on the computer configuration recommendations of Glodon Software from many aspects to help readers choose a suitable computer configuration processor. Glodon Software requires a large amount of data calculation and processing when performing architectural design, simulation and other operations. Therefore, the requirements for the processor are higher. It is recommended to choose a multi-core, high-frequency processor, such as Intel i7 series or AMD Ryzen series. These processors have strong computing power and multi-thread processing capabilities, and can better meet the needs of Glodon software. Memory Memory is affecting computing

Rules and exceptions for pointer comparisons? Rules and exceptions for pointer comparisons? Jun 04, 2024 pm 06:01 PM

In C/C++, the pointer comparison rules are as follows: pointers pointing to the same object are equal. Pointers to different objects are not equal. Exception: Pointers to null addresses are equal.

What is the best graphics card driver version? (Which graphics card driver version is the best) What is the best graphics card driver version? (Which graphics card driver version is the best) Jan 10, 2024 pm 11:13 PM

Which version of the graphics card driver is best to use? 1. There is no absolute best version. It is most important to choose the version that suits your computer; 2. Because the applicability and stability of the graphics card driver version are related to the computer hardware environment and system configuration; 3. You can check the detailed information of the computer and graphics card on the official website, select the appropriate driver version based on the information, or refer to the reviews of other users. It is recommended to back up the system before installing the driver to avoid unexpected situations. Graphics card driver version 472.19 series is an excellent choice. Currently, the driver compatibility of version 472 is the best. Installing version 472 of the driver can also maximize the performance of the graphics card. The NVIDIA graphics card driver Win7 installation version, numbered 2, 472.19, is a product with remarkable quality.

Please recommend a cost-effective 1155-pin CPU Please recommend a cost-effective 1155-pin CPU Jan 14, 2024 pm 01:30 PM

Please recommend which 1155-pin CPU is the best. The current 1155-pin CPU with the highest performance is Intel Corei7-3770K. It has 4 cores and 8 threads, a base frequency of 3.5GHz, and supports TurboBoost2.0 technology, which can reach up to 3.9GHz. In addition, it is equipped with 8MB of level 3 cache and is an excellent processor with the LGA1155 pin, the most powerful CPU Intel Core i73770K. The LGA1155 interface is the interface type used by second and third generation Core processors. The best performing one is Intel Core i73770K. The parameters of this processor are as follows: 1. Applicable type: desktop; 2. CPU series: Core i7; 3. CPU

I am going to travel to Tibet with a backpack. ① How many liters of bag is suitable for me to carry? Please tell me what you think is the best configuration. I am 170 and have good physical strength for the first time. I am going to travel to Tibet with a backpack. ① How many liters of bag is suitable for me to carry? Please tell me what you think is the best configuration. I am 170 and have good physical strength for the first time. Jan 07, 2024 am 10:06 AM

I am planning to go backpacking in Tibet. ① How many liters of bag should I carry? Please tell me what you think is the best configuration. I am 170 and have good physical strength. The first time I went hiking, the amount was 60 liters or more. The amount of hiking was less than 60 liters. The entire journey was by car. You don’t need a backpack, a suitcase is more convenient. If you really need to carry something with you, a 25-40 liter bag is more than enough. Necessary supplies for Tibet travel: sunglasses, sun hat, sunscreen, skin cream, lip balm, long-sleeved top, Sweater; for special travel or travel to Ali, northern Tibet, and Sichuan-Tibet line, it is recommended to bring: sleeping bag (cold protection), sheets (dirty protection), down jacket, travel shoes or hiking shoes, slippers, toothbrush, toothpaste, towel, rolling paper , paper underwear, disinfectant wipes, flashlight, waterproof matches, knives, rope. Can a computer be carried in the front bag? Can a computer be carried in the front bag? Some backpacks have it.

See all articles