Grep与正则表达式

Luc*_*che 3 regex linux bash grep

考虑这个文本文件:

TEST FILE : test                         #No match
                                         #No match
Run grep "1133*" on this file            #Match
                                         #No match
This line contains the number 113.       #Match
This line contains the number 13.        #No match
This line contains the number 133.       #No match
This line contains the number 1133.      #Match
This line contains the number 113312.    #Match
This line contains the number 1112.      #No match
This line contains the number 113312312. #Match
This line contains no numbers at all.    #No match
Run Code Online (Sandbox Code Playgroud)

grep命令如何评估1133*正则表达式?

为什么该行包含113正数?

正则表达式是否1133*意味着除了查找包含该单词的所有行之外的其他内容1133+anything else

此示例位于tldp文档页面上.

Wis*_*guy 8

你正在考虑一个shell通配符,*匹配任何东西.在正则表达式中,a *是一个量词,意思是"零或更多"之前的任何东西,在这种情况下是3.

所以你的表达式意味着113零或多个3s.