Linux regular expressions, linux Regular Expressions

Source: Internet
Author: User
Tags character classes

Linux regular expressions, linux Regular Expressions

POSIX standard classifies regular expressions into two types: Basic Regular Expressions> extended regular expressions. Most linux applications and tools only support basic regular expressions. =========== Basic regular expression metacharacters and their meanings =====================* matches 0 or more. match any character ^ match start with $ match end with [] match character set with \ Escape Character \ <\> exact match symbol \ {n \} match previous character appears n times \ {n, \} match the previous character to appear at least n times \ {n, m \} match the previous CHARACTER n-m times ============================== ======================================== match empty rows: ^ $ \ <\> indicates exact match symbol \ <the \> indicates matching the word, but not matching words that contain the character, such as then, them, there, another and other awk, linux tools such as perl also support regular expression extended characters ================ ===============================? Match 0 or 1 common character before it + match 1 or more common characters before it () indicates a character set or used in expr | indicates 'or ', match a set of optional characters =========================================== ====================================== the wildcard bash shell itself does not support regular expressions, shell commands and tools support wildcard characters ====================================== ======================================= * any character of any bit? Any character [] represents a combination of expressions in the range of {}. These expressions indicate the relationship between 'and' ^. Return the inverse example: ls-l *. awk. ls-l 0 ?. Pem starts with 0, followed by a character, and the suffix is. pem file ls-l [a-h] *. awk starts with [a-h. awk file ls-l [a-h] *. [^ awk] * a file starting with [a-h] With a suffix of not awk ls-l {[a-h] *. awk, 0 ?. Pem} starts with 0, followed by a character, and the suffix is. pem files or files starting with [a-h. awk file ============================================ ============================== POSIX in order to maintain the consistency of character encoding in different countries, POSIX (Portable Operating System Interface) adds special character classes, which are given in the format of [: classname]. The grep command supports POSIX character classes. ================== POSIX =================================== ================= Class Name meaning [: upper:] [A-Z] [: lower:] [a-z] [: digit:] [0-9] [: alnum:] [0-9a-zA-Z] [: space:] space or Tab [: alpha:] [a-zA-Z] [: cntrl:] ctrl key [: graph:] or [: print:] the character [: xdigit:] Between ASCII code 33-126 hexadecimal number [0-9a-fA-F] ================================== ======================================

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.