PatternModifiers-规则表达式的修饰符(转载)发现PHP里有些正则_PHP
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. 目前还没有其他的控制特征

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What does WeChat Do Not Disturb mode mean? Nowadays, with the popularity of smartphones and the rapid development of mobile Internet, social media platforms have become an indispensable part of people's daily lives. WeChat is one of the most popular social media platforms in China, and almost everyone has a WeChat account. We can communicate with friends, family, and colleagues in real time through WeChat, share moments in our lives, and understand each other’s current situation. However, in this era, we are also inevitably faced with the problems of information overload and privacy leakage, especially for those who need to focus or

iOS devices have long been able to track your sleep patterns and more using the Health app. But isn’t it annoying when you’re disturbed by notifications while you’re sleeping? These notifications may be irrelevant and therefore disrupt your sleep patterns in the process. While Do Not Disturb mode is a great way to avoid distractions while sleeping, it can cause you to miss important calls and messages you receive during the night. Thankfully, this is where sleep mode comes in. Let’s learn more about it and how to use it on iPhone. What role does sleep mode play on the iPhone? Sleep mode is a dedicated focus mode in iOS that is automatically activated based on your sleep schedule in the "Health" App. It helps you set an alarm and then

Even answering calls in Do Not Disturb mode can be a very annoying experience. As the name suggests, Do Not Disturb mode turns off all incoming call notifications and alerts from emails, messages, etc. You can follow these solution sets to fix it. Fix 1 – Enable Focus Mode Enable focus mode on your phone. Step 1 – Swipe down from the top to access Control Center. Step 2 – Next, enable “Focus Mode” on your phone. Focus Mode enables Do Not Disturb mode on your phone. It won't cause any incoming call alerts to appear on your phone. Fix 2 – Change Focus Mode Settings If there are some issues in the focus mode settings, you should fix them. Step 1 – Open your iPhone settings window. Step 2 – Next, turn on the Focus mode settings

The epc+o model refers to the general contracting framework that integrates design, procurement, etc. It is some operational links derived from epc; that is, during the construction period, the general contractor must not only undertake design tasks in the traditional sense In addition, it also has to undertake all maintenance tasks during the operation period. This model can greatly improve the operational efficiency of many projects and quickly reduce operating costs.

How to use AutoCorrect to type arrows in Word One of the fastest ways to type arrows in Word is to use the predefined AutoCorrect shortcuts. If you type a specific sequence of characters, Word automatically converts those characters into arrow symbols. You can draw many different arrow styles using this method. To type an arrow in Word using AutoCorrect: Move your cursor to the location in the document where you want the arrow to appear. Type one of the following character combinations: If you don't want what you type to be corrected to an arrow symbol, press the backspace key on your keyboard to

A superscript is a character or characters, either letters or numbers, that you need to set slightly above the normal line of text. For example, if you need to write 1st, the letter st needs to be slightly higher than the character 1. Likewise, a subscript is a group of characters or a single character and needs to be set slightly lower than normal text level. For example, when you write a chemical formula, you need to place the numbers below the normal line of characters. The following screenshots show some examples of superscript and subscript formatting. Although it may seem like a daunting task, applying superscript and subscript formatting to your text is actually quite simple. In this article, we will explain in some simple steps how to easily format text using superscript or subscript. Hope you enjoyed reading this article. How to apply superscript in Excel

Windows in S mode is designed to provide enhanced security and performance by only allowing the installation of apps from the Microsoft Store. While this feature helps prevent malware and ensure a secure computing environment, it may limit users who want to install applications from sources other than the Microsoft Store. If you find yourself in this situation and keep asking yourself how to switch out of S mode in Windows 10/11, then you have come to the right place as we will walk you through how to switch out in Windows 10/11 using two different methods Steps to S Mode ensure you can enjoy the freedom of installing apps from anywhere you choose. Learn how to switch out of S mode in Windows

On iPhone 15 Pro and iPhone 15 Pro Max models, Apple introduced a physically programmable action button that replaces the traditional ring/silent switch above the volume buttons. The action button can be programmed to perform several different functions, but the ability to switch between silent and ring modes isn't gone. By default, a long press on the action button will silence the device and the button's tactile feedback will pulse three times. Both iPhone 15 Pro models will display a crossed-out bell symbol next to the time in the status bar to indicate that silent/silent mode is activated, and it will remain so until you long-press the Action button again to unmute the device. If you prefer to put your iPhone in silent mode
