"Regular expression" practice log

Source: Internet
Author: User

The main use of the form of asking and answer, to express some of the special 0 basis of the regular expression will encounter some problems to be recorded.

We know that regular expressions match strings with a series of rules. In the boundless character of the sea, how to find the "it" you want, obviously there is a certain technical content.

Someone would ask, what's so hard about finding a string? You see, finding "goddess" two words is not minutes?

Yes, finding this is really, not a lot of things are like that. The following expands.

  1. Exact match

As said above, want to find what direct input on it, why go through the trouble.

e.g: Goddess

If you're looking for a noun, not a part of a sentence, how do you deal with it?

For example: "Thousands of degrees" and "Baidu" is obviously not a thing, but if you enter "Baidu", two will come out. Orz, too retarded, I clearly as long as Baidu this word, why find "thousands of degrees" in, think is also drunk. So, we need to use some tricks in it, and we'll mention it later. Of course, regular expressions are not all that can be handled, such as this example.

  

  2. Meta-characters

  \d------> Digital

Q: I want to find a number, what should I do?

A: Direct input ah, silly bar.

Q: What I'm looking for is not a fixed number, it's any of the 0-9. Is there any way?

A: Do you mean to have something to replace the expression number? So you can do it once and for all? Here is a "\d" you take it.

Q: This will satisfy the requirements? How do I remember this, and how do you know that \d represents numbers, not others? Why the \d, not the \s?

A: You can understand that \d stands for digit. This is obviously easy to remember.

\d------> Digital

"Regular expression" practice log

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.