Regular expression matches any string __ regular expression

Source: Internet
Author: User

(.*?) Match all strings


<p class= "num" >9033</p>

such as using <p class= "(. *?)" >9033</p>

Will get num


However, if a newline character is invalidated, and if a match is required, including a newline character, use the

([\s\s]*)

If you have parentheses or other metacharacters in an expression, you need to use escape. Before the character, add a \

Metacharacters

Description

Example

^

Matches the starting position of the entire string, or the starting position of the line, or the excluded type (negative) character group if it is inside a character group

^start

$

Matches the end position of the entire string, or the end position of the line

end$

()

grouping, providing reverse reference (GOURP1) \1 or multiple-selection branches

(AB) +

* + ?

quantifiers, limiting the number of times before elements appear

+ (AB) +

.

Matches any character other than a newline character by default, and can match line breaks in multiple-line mode

[

Start symbol for character group

[0-9]

\

A backslash is used to represent an escape sequence, or to remove the escape of a meta character

\1

{

Start of the recurrence qualifier

{2, 6}

|

Dividing multiple-selection branches (when parentheses do not appear, you can imagine parentheses appearing at the outermost end of the entire expression)

Tom| Jerry


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.