正则表达式匹配不包含单词的行 - Regular expression to match a line that doesn't contain a word

问题:

I know it's possible to match a word and then reverse the matches using other tools (eg grep -v ). 我知道能够匹配一个单词,而后使用其余工具(例如grep -v )反转匹配。 However, is it possible to match lines that do not contain a specific word, eg hede , using a regular expression? 可是,是否可使用正则表达式匹配不包含特定单词(例如hede )的行? 正则表达式

Input: 输入:

hoho
hihi
haha
hede

Code: 码:

grep "<Regex for 'doesn't contain hede'>" input

Desired output: 所需的输出:

hoho
hihi
haha

解决方案:

参考一: https://stackoom.com/question/1hg6/正则表达式匹配不包含单词的行
参考二: https://oldbug.net/q/1hg6/Regular-expression-to-match-a-line-that-doesn-t-contain-a-word
相关文章
相关标签/搜索