需求:
有如下文本,需要找出不含“ hede “的行, 不要告诉我用 grep -v ,我要纯正则表达式。
hoho
hihi
haha
hede
有如下文本,需要找出不含“ hede “的行, 不要告诉我用 grep -v ,我要纯正则表达式。
hoho
hihi
haha
hede
|
1
目前搜到离答案最近的是
http://stackoverflow.com/questions/406230/regular-expression-to-match-a-line-that-doesnt-contain-a-word 但悲剧的是我自己用 grep '^((?!hede).)*$' b.txt 居然没用。 |
|
3
|
|
54c3Mar 2, 2017
4
|
|
5
http://regex.alf.nu/
考验功力上这个啊 |
|
hellogbkMar 2, 2017
6
^(?!.*hede.*).*$
|
|
ProkillerJMar 2, 2017
7
5 楼那个网站已经把正则玩出花了,不怕虐的可以去试一下
|
|
DiamondbacKMar 2, 2017
8
Use `grep -P pattern`.
|
|
wojiaodaxiaxiaMar 2, 2017
9
6 楼应该是最准确直观的答案了吧
|
|
kinghsMar 2, 2017 via iPhone
11
^(?!.*hede).*$
|
|
ColinZebMar 2, 2017
12
@langmoe afoot|catfoot|dogfoot|fanfoot|foody|foolery|foolish|fooster|footage|foothot|footle|footpad|footway|hotfoot|jawfoot|mafoo|nonfood|padfoot|prefool|sfoot|unfool
|
|
pysamaMar 2, 2017
14
/^(?!.*hede).*$/gi
|
|
16
|
|
lianyueMar 2, 2017
21
js
/(^|\n)((?:(?!hede).)+)(?=\n|$)/g ..其他的 支持 后断言 的 /(?<=^|\n)(?:(?!hede).)+(?=\n|$)/g |
|
mdzzMar 2, 2017
23
LZ 可能是想要一个 ABAB 叠字的正则
|
|
26
|
|
nicevarMar 3, 2017
27
正则功力几乎为 0 ,每次都是用的时候不断尝试,或者直接问同事
|
|
flfwzglMar 3, 2017
28
`hoho
hihi haha fahedewwf`.replace(/\n.*hede.*\n?/g, '\n') |