Reputation: 17785
I am trying to look for a regular expession for might have a space. I am searching for occurences of
word1word2
and
word1 word2
I try:
grep "word1[ +]word2" mylog.txt
But this does not work.
Any ideas?
Upvotes: 1
Views: 105
Reputation: 1234
Try "word1\s*word2"
.
If you would only want zero or one space you could try "word1\s{0,1}word2"
Btw: the + or * would follow after the brackets: [ ]+
Upvotes: 0
Reputation: 255
Following regex should do the trick:
x *y
It will check for any number of spaces between x and y.
Upvotes: 1