Regular Expression (Regular Expression)

Source: Internet
Author: User
Tags printable characters

Regular Expression
It is a text mode consisting of common characters (such as characters a to z) and special characters (called metacharacters. A regular expression is used as a template to match a character pattern with the searched string.
You can construct a regular expression by adding various components in expression mode between a pair of delimiters, that is,/expression/
Common characters
It consists of all the print and non-print characters that are not explicitly specified as metacharacters. This includes all uppercase and lowercase letter characters, all numbers, all punctuation marks, and some symbols.
Non-printable characters
Character meaning
Cx matches the control characters specified by x. For example, cM matches a Control-M or carriage return character. The value of x must be either a A-Z or a-z. Otherwise, c is treated as an original 'C' character.
F matches a form feed. It is equivalent to x0c and cL.
Match A linefeed. It is equivalent to x0a and cJ.
Match a carriage return. It is equivalent to x0d and cM.
S matches any blank characters, including spaces, tabs, and page breaks. It is equivalent to [fv].
S matches any non-blank characters. It is equivalent to [^ fv].
Match a tab. It is equivalent to x09 and cI.
V matches a vertical tab. It is equivalent to x0b and cK.
Special characters
Special characters are characters with special meanings, such as *. txt. in simple words, they represent the meaning of any string. If you want to find a file with * in the file name, you need to escape *, that is, add one before it. Ls *. txt. Regular expressions have the following special characters.
Special characters
$ Matches the end position of the input string. If the Multiline attribute of the RegExp object is set, $ also matches ''or ''. 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 line breaks. 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, please 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 '. ''Matches the linefeed. 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 ^.

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.