3.2 re -- Regular expression operations, re -- regular

Source: Internet
Author: User

3.2 re -- Regular expression operations, re -- regular

This module provides regular expression matching operations. Its functions are the same as those in Perl.


Whether it is a Unicode string or a single-byte 8-Bit String, you can use the pattern matching and string search functions. However, it should be noted that Unicode strings and 8-bit strings cannot be used in combination, that is, you cannot match the single-byte mode in Unicode, or other search functions. Similarly, strings cannot be replaced with each other in different types of strings.


Regular Expressions use backslash ('\') to specify the meaning of a specific format, or allow specific characters. To solve the problem of using the backslash ('\'), the solution is the same as that used in string formatting. For example, to match a double backslash ('\'), you need to use the '\' format, because each two double backlash ('\') represents a diagonal line.


However, you can also use another method to represent the string of a regular expression. You do not need to use this troublesome method, that is, use the start of the 'R' character to represent the processing of the original string. For example, writing R' \ n' is a string that represents two characters: \ and n. If the string '\ n' does not start with r, It is a character string, it indicates a newline character.


One thing to note is that all functions and methods related to regular expressions are in the section of the object for compiling regular expressions, but it does not mean that these functions and methods can be used only by compiling regular expressions, but it can be used directly, but there will be some performance loss, or you need to enter more parameters.

Cai junsheng QQ: 9073204 Shenzhen

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.