Wildcards and regular expressions are easy to confuse. First, you must understand that the two are different. I personally think that Wildcards are used in shell commands (such as file name-related operations) in Linux, the regular expression is used to search and replace strings in text content. Wildcards are supported by the Linux system, while regular expressions are used in the vim editor or awk.ProgramThese text processing tools become powerful just because they support regular expressions.
- Wildcard
- [A-Z] or [12]: match a single character or one of the characters listed in square brackets within a specified range.
- [! 9]: does not match the characters listed in square brackets or a single character within the specified range.
- *: Matches 0 or multiple characters.
- ? : Matches any single character and cannot be a null character.
Because shell will change the character? [] * Special characters. Therefore, if you need to use these special characters in a command parameter, you should mark the parameter with single quotation marks or add escape characters \ before special characters \.
- Regular Expression
- .: Match any single character. Is it in the function and wildcard? The symbols are the same.
- [A-Z] or [12]: The function is the same as [] in the wildcard.
- [^]: [!] In functions and wildcards Same.
- *: The occurrence of the first character that matches the character 0 or multiple times.
- ^: Match all rows starting with the specified regular expression.
- $: Match all rows ending with a specified regular expression.
Note that special characters in [], for example, have lost their special meanings, are the same as common characters in [12] in square brackets.
Original article: http://www.cnblogs.com/sujz/archive/2011/12/14/2288164.html