I have currently a set of seds that's working well except for one thing.
The particular expression I'm having an issue with is:
sed -i '/[^}.to]\.to[[:space:]]/ s/\(\S\)/expect(\1/' ../_spec_seded/"$file"
Right now this works fine.
Basically it looks for .to
and insert expect
at the start of the expression.
In particular, it excludes }.to
when looking to match on .to
which works.
Now I want to also exclude 'this' or 'that' from the search match. In my case }.to
or end.to
i.e. instead of
/[^}.to]\.to[[:space]]/
should I have:
/[^}.to|^end\.to]\.to[[:space]]/
/[^}.to][^end\.to]\.to[[:space]]/
/[(^}.to|end\.to)]\.to[[:space]]/
/[^(}.to|end\.to)]\.to[[:space]]/
would I even need to escape parens if using them like
/[^\(}.to|end\.to\)]\.to[[:space]]/
or even the |
as well?
/[^\(}.to\|end\.to\)]\.to[[:space]]/
I'm trying to make the match work on:
stuff.to do thing
stuff).to do thing
this.to that
all.all.all.to do
pretend.do # Note this edge case! (pretend contains "end"!)
but not on
this will be here }.to do
last.end}.to do
all.this at the end.to
none at allend.to
and
all.this at the
end.to # i.e. no spaces before as it is the start of the line.
Negating with OR's generally (all languages) seems tricky (due to false positives).
pretend.do
andnone at allend.to
cases that one should match and the other shouldn't? And how comepretend.do
matches when it doesn't have a\.to[[:space:]]
?