Regular expressions and wildcards in Linux

       Regular expressions and wildcards are two completely different things, and these two things are especially confusing. Wildcards are a feature of the bash interface, while regular expressions are expressions for string processing.

        especially"*". The * in the wildcard represents the meaning of 0 to n characters; the regular expression is 0 or unlimited of the previous RE character.

        "?" in regular expressions 0 or one of the preceding RE characters; in wildcards it means one character.

        "+" precedes one or more RE characters in a regular expression.

        Regular expressions and wildcards "[]" can represent a range. For example, "[az]" represents 26 lowercase English letters. Of course, pay attention to language issues. For language issues, see another blog post.

        The regular expression "{}" represents the number of occurrences of the previous character, for example, the previous character appears 2 to 5 times, and 'he{2,5}' means e appears 2 to 5 times.

        The regular expression "()" represents a string of groups, and "g(la|oo)d" represents the glad or good character.

 

       "?, +, ()" etc. belong to extended regular expressions, in linux grep command needs to use egrep instead

        

      

        

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326035784&siteId=291194637