Detailed explanation of regular expression \w \d usage
Regular expression is a special string pattern, used to match a set of strings, just like using a mold to make products, and regular expression is this mold, defining a rule to match characters that match the rules. This article mainly introduces the meaning of regular expression \w \d. Friends who need it can refer to
I believe many people know about regular expressions, but the first feeling of many people is that it is difficult to learn. Because when I first looked at it, I felt that there was no pattern at all, and it was all a bunch of special symbols, completely incomprehensible.
In fact, it’s just because you don’t understand regular rules. Once you understand them, you will find that that’s it. There are actually not many related characters used in regular rules, and they are not difficult to remember, let alone understand. The only difficulty is the combination. After getting started, the readability is relatively poor and it is not easy to understand. The purpose of this article is to let everyone have a basic understanding of regular expressions, be able to understand simple regular expressions, and write simple regular expressions to meet daily needs. Just meet the needs under development.
What is a regular expression
A regular expression is a special string pattern used to match a set of strings. It's like using a mold to make a product, and regular rules are this mold, defining a rule to match characters that match the rules.
After consulting many related regular descriptions, I found that the definition of \w refers to containing uppercase and lowercase letters, numbers and underscores, which is equivalent to ([0-9a-zA-Z])
(Based on the classic regular expression 30-minute introductory tutorial)
However, in actual use, it is found that this is not the case. It can also be said that it actually includes more than just ([0-9a -zA-Z_])
These data,
The following is the test screenshot tool for editplus:
actually except ([0 -9a-zA-Z_])
also includes Greek letters, Russian letters, etc.;
So if you need to pay attention to the specific matching data when registering user information, you must not use it directly \w Done
PS: Let’s look at the regular expression \w \s \d \b
. Matches any character except newline characters
\w Matches letters or numbers or underscores or Chinese characters, which is equivalent to '[^A-Za-z0-9_]'.
\s Matches any whitespace character
\d Matches digits
\b Matches the beginning or end of a word
^ Matches the beginning of a string
$ Match the end of the string
\wWhether Chinese characters can be matched depends on your operating system and your application environment
The above is the detailed content of Detailed explanation of regular expression \w \d usage. For more information, please follow other related articles on the PHP Chinese website!

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

Windows operating system is one of the most popular operating systems in the world, and its new version Win11 has attracted much attention. In the Win11 system, obtaining administrator rights is an important operation. Administrator rights allow users to perform more operations and settings on the system. This article will introduce in detail how to obtain administrator permissions in Win11 system and how to effectively manage permissions. In the Win11 system, administrator rights are divided into two types: local administrator and domain administrator. A local administrator has full administrative rights to the local computer

Detailed explanation of division operation in OracleSQL In OracleSQL, division operation is a common and important mathematical operation, used to calculate the result of dividing two numbers. Division is often used in database queries, so understanding the division operation and its usage in OracleSQL is one of the essential skills for database developers. This article will discuss the relevant knowledge of division operations in OracleSQL in detail and provide specific code examples for readers' reference. 1. Division operation in OracleSQL

How to use the exit function in C language requires specific code examples. In C language, we often need to terminate the execution of the program early in the program, or exit the program under certain conditions. C language provides the exit() function to implement this function. This article will introduce the usage of exit() function and provide corresponding code examples. The exit() function is a standard library function in C language and is included in the header file. Its function is to terminate the execution of the program, and can take an integer

WPS is a commonly used office software suite, and the WPS table function is widely used for data processing and calculations. In the WPS table, there is a very useful function, the DATEDIF function, which is used to calculate the time difference between two dates. The DATEDIF function is the abbreviation of the English word DateDifference. Its syntax is as follows: DATEDIF(start_date,end_date,unit) where start_date represents the starting date.

The modulo operator (%) in PHP is used to obtain the remainder of the division of two numbers. In this article, we will discuss the role and usage of the modulo operator in detail, and provide specific code examples to help readers better understand. 1. The role of the modulo operator In mathematics, when we divide an integer by another integer, we get a quotient and a remainder. For example, when we divide 10 by 3, the quotient is 3 and the remainder is 1. The modulo operator is used to obtain this remainder. 2. Usage of the modulo operator In PHP, use the % symbol to represent the modulus

Detailed explanation of Linux system call system() function System call is a very important part of the Linux operating system. It provides a way to interact with the system kernel. Among them, the system() function is one of the commonly used system call functions. This article will introduce the use of the system() function in detail and provide corresponding code examples. Basic Concepts of System Calls System calls are a way for user programs to interact with the operating system kernel. User programs request the operating system by calling system call functions

How to use Apple shortcut commands With the continuous development of technology, mobile phones have become an indispensable part of people's lives. Among many mobile phone brands, Apple mobile phones have always been loved by users for their stable systems and powerful functions. Among them, the Apple shortcut command function makes users’ mobile phone experience more convenient and efficient. Apple Shortcuts is a feature launched by Apple for iOS12 and later versions. It helps users simplify their mobile phone operations by creating and executing custom commands to achieve more efficient work and

The ISNULL() function in MySQL is a function used to determine whether a specified expression or column is NULL. It returns a Boolean value, 1 if the expression is NULL, 0 otherwise. The ISNULL() function can be used in the SELECT statement or for conditional judgment in the WHERE clause. 1. The basic syntax of the ISNULL() function: ISNULL(expression) where expression is the expression to determine whether it is NULL or
