Regular expression (Regular Expression)

Source: Internet
Author: User
Regular expressions
is a literal pattern consisting of ordinary characters, such as characters A through z, and special characters (called metacharacters). A regular expression is used as a template to match a character pattern with the string being searched for.
You can construct a regular expression by putting together various components of an expression pattern between a pair of delimiters, namely/expression/
Ordinary characters
Consists of all print and nonprinting characters that are not explicitly specified as metacharacters. This includes all uppercase and lowercase alphabetic characters, all numbers, all punctuation marks, and some symbols.
Non-printable characters
Character meaning
CX matches the control characters indicated by X. For example, CM matches a control-m or carriage return character. The value of x must be one-a-Z or a-Z. Otherwise, c is treated as a literal ' C ' character.
F matches a page feed character. Equivalent to x0c and CL.
Matches a line feed character. Equivalent to x0a and CJ.
Matches a carriage return character. Equivalent to x0d and CM.
s matches any whitespace character, including spaces, tabs, page breaks, and so on. equivalent to [F v].
S matches any non-white-space character. equivalent to [^ f v].
Matches a tab character. Equivalent to x09 and CI.
V matches a vertical tab. Equivalent to x0b and CK.
Special characters
The so-called special characters, that is, some special meaning of the characters, such as the above "*.txt" in the *, simply to say that any string meaning. If you are looking for a file with * in the file name, you need to escape the * by adding one before it. LS *.txt. Regular expressions have the following special characters.
Special Character description
$ matches the end position of the input string. If the Multiline property of the RegExp object is set, then $ also matches ' or '. 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 the *.
+ matches the preceding subexpression one or more times. to match the + character, use the +.
. Matches any single character except a newline character. to match., please use the.
[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 '. ' Matches a newline character. Sequence ' matches ', while ' (' 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, please 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.