For regular expressions, I believe a lot of people know, but a lot of people's first feeling is difficult to learn, because at the first glance, feel that there is no regular to find, and all a bunch of various special symbols, completely unintelligible. In fact, just do not understand, and understand you will find that the original is so ah, the relevant characters used in fact not much, it is not difficult to remember, more difficult to understand, the only difficult is to combine, readability is poor, and not easy to understand, this article is intended to let everyone have a basic understanding of the regular, Can read simple regular expressions, write a simple regular expression, to meet the needs of daily development.
What is a regular expression
A regular expression is a special string pattern that matches a set of strings, like a product with a mold, and a regular is the mold that defines a rule to match the character that matches the rule.
After reviewing many of the relevant regular descriptions, it is found that the interpretation of \w refers to the inclusion of uppercase and lowercase alphanumeric and underscores equivalent ([0-9a-zA-Z])
(drawn from the Classic tutorial regular expression 30-minute introductory tutorial)
But in practice, it's not the case, it can be said that it's not just about the ([0-9a-zA-Z_])
data,
Here is the test tool for EditPlus:
The actual addition ([0-9a-zA-Z_])
also contains the Greek alphabet, Russian letters, etc.;
So if you need to pay attention to the specific matching data when registering the user information, you must not use \w directly.
PS: See below the regular expression \w \s \d \b
. Match any character other than line break
\w matches letters or numbers or underscores or kanji equivalent to ' [^a-za-z0-9_] '.
\s matches any whitespace character
\d Matching numbers
\b Match the beginning or end of a word
^ Start of matching string
$ match End of string
\w can match Chinese characters depending on your operating system and your application environment
The above content is the regular expression \w \d meaning answer, hope can help everyone.