Special characters that need to be escaped in a regular summary _ Computer basics

Source: Internet
Author: User

Some special characters in regular expressions need to be escaped before they match, so here's a summary.

Special characters

Description

$ matches the end position of the input string. If the Multiline property of the RegExp object is set, then $ also matches ' \ n ' or ' \ R '. To match the $ character itself, use \$.

() marks the start and end position of a subexpression. The subexpression can be obtained for later use. To match these characters, use \ (and \).

* Match the preceding subexpression 0 or more times. To match the * character, use \*.

+ matches the preceding subexpression one or more times. to match the + character, use \+.

. Matches any single character except the newline character \ n. to match., please use \.

[] marks the beginning of a bracket expression. To match [, use \[.

? Matches the preceding subexpression 0 or more times, or indicates a non-greedy qualifier. Want to match? characters, please use \?.

\ marks the next character as either a special character, or a literal character, or a backward reference, or a octal escape character. For example, ' n ' matches the character ' n '. ' \ n ' matches line breaks. The sequence ' \ \ ' matches ' \ ' and ' \ (' matches '.

^ matches the starting position of the input string, unless used in a bracket expression, at which point it means that the character set is not accepted. To match the ^ character itself, use \^.

{} marks the beginning of a qualifier expression. To match {, use \{.

| Indicates a choice between two items. to match |, use \|.

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.