Aliasing, and another regex question

Is there a preferred way to alias inconveniently long things like
Oniguruma::ORegexp?

Is it possible to have one regex that matches all lines that have word
“foo”, but only if word “bar” doesn’t appear anywhere on the line?

Sorry for yet more questions!

J. Cooper wrote:

Is there a preferred way to alias inconveniently long things like
Oniguruma::ORegexp?

Well you can do something like OR = Oniguruma::ORegexp

Is it possible to have one regex that matches all lines that have word
“foo”, but only if word “bar” doesn’t appear anywhere on the line?

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

On Wed, Feb 27, 2008 at 1:30 PM, J. Cooper [email protected] wrote:

Is there a preferred way to alias inconveniently long things like
Oniguruma::ORegexp?

OReg = Oniguruma::ORegexp

Sounds good on the alias :slight_smile:

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.

:frowning:

J. Cooper wrote:

I was really hoping I could do it in one line

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