Summary of special characters to be escaped in Regular Expressions

Source: Internet
Author: User

If you want to find a file with * in the file name, you need to escape *, that is, add a \ before it \. Ls \ *. txt. Regular expressions have the following special characters. Escape

Special characters



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


Mark the start and end positions of a subexpression. Subexpressions can be obtained for future use. To match these characters, use \ (and \).


Matches the previous subexpression zero or multiple times. To match * characters, use \*.


Match the previous subexpression once or multiple times. To match + characters, use \ +.


Match any single character except linefeed \ n. To match., use \.


Mark the start of a bracket expression. To match [, use \[.


Match the previous subexpression zero or once, or specify a non-Greedy qualifier. To match? Character, use \?.


Mark the next character as or a special character, or a literal character, or backward reference, or an octal escape character. For example, 'n' matches the character 'n '. '\ N' matches the line break. The sequence '\' matches "\", while '\ (' matches "(".


Matches the start position of the input string. Unless used in the square brackets expression, this character set is not accepted. To match the ^ character itself, use \ ^.


Mark the start of a qualifier expression. To match {, use \{.


Specifies a choice between two items. To match |, use \ |.

So yes

Copy codeThe Code is as follows :*.? + $ ^ [] () {}| \/

The method for constructing a regular expression is the same as that for creating a mathematical expression. That is, a larger expression is created by combining a small expression with a variety of metacharacters and operators. The regular expression component can be a single character, Character Set combination, character range, choice between characters, or any combination of all these components.

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: 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.