Reputation: 527
I am trying to use regex to match strings that not end with 's, I wrote a regex like this: .*[^('s)$]$
, but it seems that this regex also cannot match a string that ends with a single s, like cats or dogs, can somebody help? thx
I am using egrep
, I have tried like
^(?!.*'s$).*
or
.*(?<!ab)$
but it seems these not working well
Upvotes: 1
Views: 139
Reputation: 784888
Look-around assertions are traditionally not supported in grep. You may be able to use
grep -v` here:
grep -v "'s$" file
-v
option is used for inver-match which is used to return lines are those not matching any of the specified patterns.
However do note in in gnu-grep
you can use experimental -P
option to use advanced PCRE features such as lookahead and lookbehind assertions.
Upvotes: 1