Skip to main content
edited tags
Link
VLAZ
  • 29.6k
  • 9
  • 65
  • 88
Add Bash syntax highlighting
Source Link
Benjamin Loison
  • 5.8k
  • 4
  • 20
  • 37

I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a regular expression?

Input:
hoho hihi haha hede 
Code:
grep "<Regex for 'doesn't contain hede'>" input 
grep "<Regex for 'doesn't contain hede'>" input 
Desired output:
hoho hihi haha 

I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a regular expression?

Input:
hoho hihi haha hede 
Code:
grep "<Regex for 'doesn't contain hede'>" input 
Desired output:
hoho hihi haha 

I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a regular expression?

Input:
hoho hihi haha hede 
Code:
grep "<Regex for 'doesn't contain hede'>" input 
Desired output:
hoho hihi haha 
Format.
Source Link
Mateen Ulhaq
  • 27.9k
  • 21
  • 121
  • 155

I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a regular expression?

Input:

Input:
hoho hihi haha hede 

Code:

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

Desired output:

Desired output:
hoho hihi haha 

I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a regular expression?

Input:

hoho hihi haha hede 

Code:

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

Desired output:

hoho hihi haha 

I know it's possible to match a word and then reverse the matches using other tools (e.g. grep -v). However, is it possible to match lines that do not contain a specific word, e.g. hede, using a regular expression?

Input:
hoho hihi haha hede 
Code:
grep "<Regex for 'doesn't contain hede'>" input 
Desired output:
hoho hihi haha 
edited tags
Link
jparanich
  • 9.2k
  • 5
  • 28
  • 37
Loading
added 3 characters in body
Source Link
Amal K
  • 5k
  • 2
  • 28
  • 56
Loading
edited tags
Link
Toto
  • 91.7k
  • 63
  • 97
  • 135
Loading
edited body
Source Link
Harsha Biyani
  • 7.3k
  • 10
  • 42
  • 64
Loading
edited body; edited title
Source Link
kvantour
  • 26.9k
  • 4
  • 57
  • 81
Loading
just making it concise 💙💙💙
Source Link
Emma Marcier
  • 27.8k
  • 12
  • 49
  • 71
Loading
edited tags
Link
Mr world wide
  • 4.9k
  • 10
  • 47
  • 105
Loading
Fixed formatting and improved clarity.
Source Link
wjandrea
  • 34k
  • 10
  • 69
  • 105
Loading
Rollback to Revision 9
Source Link
Taryn
  • 248.9k
  • 57
  • 374
  • 409
Loading
added 260 characters in body
Source Link
m87
  • 4.5k
  • 3
  • 18
  • 31
Loading
deleted 2 characters in body; edited title
Source Link
codeforester
  • 43.8k
  • 21
  • 122
  • 159
Loading
added 46 characters in body
Source Link
Marco Bonelli
  • 71.1k
  • 21
  • 129
  • 153
Loading
More accurate title
Link
Volodymyr
  • 1.3k
  • 1
  • 16
  • 28
Loading
edited title
Link
user3453226
user3453226
Loading
Minor tweaks
Source Link
Steve Chambers
  • 39.8k
  • 29
  • 179
  • 222
Loading
Question Protected by CommunityBot
+regex-negation
Link
finnw
  • 48.8k
  • 24
  • 150
  • 223
Loading
deleted 15 characters in body
Source Link
knaser
  • 1.4k
  • 7
  • 19
  • 16
Loading
added 211 characters in body
Source Link
knaser
  • 1.4k
  • 7
  • 19
  • 16
Loading
Source Link
knaser
  • 1.4k
  • 7
  • 19
  • 16
Loading
Post Made Community Wiki by CommunityBot