shell basic regular expressions

The basic regular expressions
  • The asterisk * in front of it matches the regular expression string or any number of times (including zero). For example, "* 1122" will match one or more of the 11 + 2, which may match strings would like 112,1122,112222,11223343
  • Period. Matches any character except a newline. For example, "112" 112+ will match at least one character string which may be matched 1121,122,112abc like, but does not match 112.
  • Caret ^ matches the beginning of a line, but may depend on the context, it may indicate a negative regular expression string meaning. For example, "^ abc" will only match the string abc beginning of the line.
  • Dollar sign $ at the end of a regular expression, matching end of a line. For example, "$ 123" will only match the end of the line 123, "^ $" will match a blank line.
  • Square brackets [] brackets specified in the character set matches a character. For example, "[abc]" will match the characters a, b, any c is a character, "[ah]" will match from any a ~ h is a character, "[AZ] [az]" will match any uppercase and lowercase letters, "[^ ad]" matches all characters except a ~ d a.
  • Backslash \ escapes a special character, to make this character be explained literal meaning. For example, "\ $" will represent back to his original intent, "$", rather than the end of the line represents the regular expression meaning. Similarly, "\\" sense of the word denoted "\"
  • The escape angle brackets \ <\> is used to mark a word boundary. Angle brackets must be escaped, meaning they have only letters or characters. For example, "\ <the \>" matches the word "the", but does not match "them", "there", "other", and so on.

Guess you like

Origin www.cnblogs.com/cloud-datacenter/p/12329385.html