Regular expression negate a word (not character)

On 29 Jan 2008, at 23:35, Suraj K. wrote:

Since Ruby does not have a negative look behind operator, I just
used
the negative look ahead in a backwards way, et viola!

puts a.reverse.gsub(/erit(?!.*wons)/, ‘>>>&<<<’).reverse

Aha! I like your style.

James Edward G.'s when-all-else-fails-reverse-the-data triumphs again.

Regards,
Andy S.

On Jan 30, 2008, at 9:49 AM, Andrew S. wrote:

James Edward G.'s when-all-else-fails-reverse-the-data triumphs
again.

I love that trick. :wink:

James Edward G. II

Hi all,

I know this is an old post, but was trying to do something similar and
came up with this:

((?=.snow\stire.*)|^.tire.$)

Does that meet the required need? If it’s full line matches you’re
looking for, I think it should do the trick.

Greg Bacon schreef:

Dr.Ruud:

I negated the test, to make the regex simpler: […]

Yes, your approach is simpler. I assumed from the “need it all
in one pattern” constraint that the OP is feeding the regular
expression to some other program that is looking for matches.

Yes, I assumed about the same, but thought it would be a nice
alternative anyways.
Happy Perling!


Affijn, Ruud

“Gewoon is een tijger.”