^> 在 grep 模式中是什么意思?

el *_* ab 0 linux grep regular-expression

这个命令有什么作用?

grep "<[^>]*>" inuux.xml
Run Code Online (Sandbox Code Playgroud)

在寻找什么?

Naf*_*Kay 8

可以这样解释:

<         # A literal "<" character
[^>/]*    # Anything that isn't a ">" or a "/", zero or more times
>         # Followed by a literal ">" character
Run Code Online (Sandbox Code Playgroud)

据推测,这是用于匹配 XML/HTML 标签。它当然不是世界上最好的正则表达式,但它快速、肮脏,并且可能有效。

  • 用正则表达式解析 HTML——[总是一个好的决定](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) (6认同)