Hongmu Notes
Home Summary of pitfalls What are the regular expression matching modifiers?
Summary of pitfalls

What are the regular expression matching modifiers?

What are the regular expression matching modifiers?

Regular expressions support various modifiers to modify the characteristics of matches. Below are some commonly used modifiers and their usage:

  1. ^: The starting position for matching a string. For example, "^a" matches "a".

  2. $: The end position of the string to match. For example, "$b" matches "b".

  3. \nMatches any newline character. For example, "\n" matches "\n".

  4. \tMatches any tab character. For example, "\t" matches "\t".

  5. \sMatches any whitespace character. For example, "\s" matches "\s".

  6. \wMatches any word character (including letters, digits, and underscores). For example, "\w" matches "\w".

  7. \DMatches any non-digit character. For example, "\D" matches "\d".

  8. \SMatches any non-word character. For example, "\S" matches "\s".

  9. \xMatches any single octal character. For example, "\x20" matches "\x20".

  10. \UMatches any Unicode character. For example, "\U0000ff" matches "\u0000ff".

  11. \VMatches any vertical escape character. For example, "\V" matches "\v".

  12. \QMatches any highlighted text. For example, "\Qthis is a test\E" matches "this is a test".

  13. \EMatches any low-contrast text string. For example, "\Ethis is a test\Q" matches "this is a test".

The combined use of modifiers can be employed for more precise matching control. For example, one can use ^$ Use modifiers to match both the beginning and the end of a string, together. \n Modifiers to match any newline character, and so on.

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Browser caching increases the speed of secondary visits to your website

Browser caching increases the speed of secondary visits to your website Summary of pitfalls

Use browser caching of official words: If users will visit your website multiple times, browser caching of static resources can save users time. Cache headers should be applied to all cacheable static resources, not just to a small subset of static resources (for example, images). Cacheable resources include JS and CSS files, image files, and other binary object files (media files, PDF files, etc.). Normally, HTML doesn’t…
👁 201

Recommended reading

PHP implode() function

PHP implode() function Language Notes PHP

The function combines array elements into a single string: <code>PHP arr = array('Hello', 'World!', 'I', 'love', 'Shanghai!'); echo implode(", arr);</code>
👁 175
(Adaptive mobile version) English-language foreign trade ballet shoe website using PBootCMS template; Download source code for a Latin dance shoe website – 0394

(Adaptive mobile version) English-language foreign trade ballet shoe website using PBootCMS template; Download source code for a Latin dance shoe website – 0394 Practical Collection pbootcms Template

An adaptive mobile-friendly English-language PbootCMS website template for foreign trade ballet and Latin dance shoe brands. Featuring a fashionable, international design style, this template is ideal for dance shoe companies to showcase their product ranges and export advantages. It helps Chinese footwear manufacturers promote their brands in overseas markets and secure international orders. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5....
👁 44
(Adaptive mobile version) Blog and News Website Template – Cross-Border E-Commerce Blog Website Source Code Download – 1123

(Adaptive mobile version) Blog and News Website Template – Cross-Border E-Commerce Blog Website Source Code Download – 1123 Practical Collection pbootcms Template

A PbootCMS website template designed for blog-based news and cross-border e-commerce platforms, compatible with both PC and WAP devices. Its clean, information-flow design is ideal for cross-border e-commerce professionals to share industry trends, operational insights, and personal perspectives. This template helps e-commerce bloggers build their personal brand and online influence. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5....
👁 67
Beef Cattle Farming Supply Base Website Template 0703

Beef Cattle Farming Supply Base Website Template 0703 Practical Collection Yiyou template

This EyouCMS template is ideal for beef cattle farming and supply bases. Its natural yet professional design effectively showcases the farming environment, cattle breeds, product offerings, and breeding techniques. It helps livestock farming enterprises demonstrate their capabilities online and expand their sales channels. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (Ey...
👁 60
Firefox web development and debugging enable forced refresh cache mode

Firefox web development and debugging enable forced refresh cache mode Summary of pitfalls

Clearing the cache in Fox Browser can be tricky; using shortcuts like Ctrl+F5 or Ctrl+R doesn't work in Google Chrome or Internet Explorer. Clearing the cache in Firefox is also quite cumbersome—the default shortcut (Ctrl+Shift+Del) opens a pop-up window for selective cleanup, requiring additional clicks to confirm; this is very inconvenient and not ideal for web development and debugging. To disable local caching in Firefox, you need to go to its Preferences and configure the settings accordingly: Firefox Browser...
👁 321