[Original] Perl Regular Expression Basics

Source: Internet
Author: User
Tags perl regular expression

. Any single-character wildcard (except \ n)
* Matches the previous content zero or multiple times.
+ Match the preceding content once or multiple times.
? Match the previous content zero or once.
Non-Greedy symbols.
() Mode group
\ 1 reverse (repeated) references the matching text in parentheses.
| Or (select one matching)
[] Character set. Eg: [A-Za-Z], [abcxyz]
^ Except for the delimiters. It is only used in character sets.
\ D Number
\ W word character (number, letter and underline) [a-zA-Z0-9 _]
\ S blank characters (equivalent to [\ f \ t \ n \ r])
\ D non-numeric
\ W non-word
\ S is not blank
The number of occurrences of {} characters. Eg:/a {5, 15}/the letter A appears 5 to 15 times. /(Fred) {3,}/repeated more than 3 times
+? Non-Greedy +
*? Non-Greedy *
.? Non-greedy.
--------------------------------
The boundary anchor of the \ B word is a match of the word (\ W. \ B Non-word boundary position.
^ Match character | ^ the anchor is used to mark the start of a string.
$ Match the character ending with a character | $ the anchor is used to identify the end of a string (including a line break)
--------------------------------
/I case-insensitive
/S any character (used with., which can represent \ n)
/Add spaces to X (spaces and tabs are omitted)
/G Global replacement (replace all matches)
/M multi-line match (line break \ n can be matched)
Eg:/Barney. * Fred/s
/-? \ D + \.? \ D */x
/Barney. * Fred/is both/I and/s
--------------------------------
\ U to uppercase
\ L to lowercase
\ U and \ l will only convert the first character

 

 

Related Article

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.