Regular Expressions \w \d usage

Source: Internet
Author: User
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. This article mainly introduces the meaning of regular expression \w \d, the need for friends can refer to the following

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.