The best way would probably be to just use two regexen. One to select
all
lines with foo and another to filter out those with bar.
HTH,
Sebastian
I figured… I was really hoping I could do it in one line, as this was
a regex I was using in a text editor (TextMate) to find all lines in a
group of files that contained one word but not another.
Well, you can do it in one line just not with a single regex (or maybe
you can do that too, but that’d probably more complicated and possibly
longer):
lines.select {|l| l =~ /foo/ && l !~ /bar/}
HTH,
Sebastian
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.