Some basic rules for regular expressions in Centos

Source: Internet
Author: User
Tags uppercase character

  • Any single character or string of characters can match the character itself,
  • ^ Symbol (^) Indicates the start of a row; $ symbol ($) Indicates the end of a row.
  • To search for special characters (such as the $ symbol), you must add a backslash (\). For example,\$Search$Instead of the end of a row.
  • Point (.) Represents any single character. For example,ad..nIt represents five character items, the first two characters are "ad", and the last character is "n ". The two characters in the middle can be any character, but can only be composed of two characters.
  • At any time, if the regular expression is included in the slash (for example/re/), Search is performed in the order of files. If a regular expression is contained in a question mark (for example,?re?), Search is performed in reverse order of files.
  • Square brackets ([]) Indicates multiple values, minus signs (-) Indicates the value range. For example,[0-9]And[0123456789]Same,[a-z]It is equivalent to searching for any lowercase character. If the first character of a list is a ^ symbol, it matches any character that is not in this list.

Table 1 shows how these rules are actually matched.

Table 1. Regular Expression examples [abc]Match one of "a", "B", and "c" [a-z]Match any lowercase character from "a" to "z" [A-Z]Match any uppercase character from "A" to "Z" [0-9]Match any number from 0 to 9 [^0-9]Match any character except 0 to 9 digits [-0-9]Match any number from 0 to 9, or a hyphen (-) [0-9-]Match any number from 0 to 9, or a hyphen (-) [^-0-9]Match any character except numbers and hyphens (-) from 0 to 9 [a-zA-Z0-9]Match any character or number

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.