From: Joseph Pecoraro Date: 2008-01-26T13:44:33+09:00 Subject: Re: regular expression negate a word (not character) SpringFlowers AutumnMoon wrote: >> May I ask why there is the requirement for a single regular expression? > > thanks for your post. a reason is that some text editor lets users > search all files using a regular expression... another reason is > that... if 2 lines are used to test... then what if that line actually > has tire and snowtire... then it may negate the whole line as a > result, even though we want to grep it due to the first word "tire". This is rather interesting to me. I recently (Dec-Jan) wrote a little find/replace Ruby script that can deal with multiple files. I call the utility rr. What you're suggesting is a pretty cool idea and opens a number of possible improvements that I did not think about. I can extend rr to take multiple regular expressions, and allow the user to say yes match this regex and No do not match this regular expression. I could also simply add an option to print out only the files where the Regular Expressions has a match, not performing the find/replace. I will have to think this through, especially this Sunday when I have more time. I am sorry that this doesn't help you with your search for a single regular expressions solution but I want to repeat that this seems so much easier using two regular expressions that I think developing such a utility would be worthwhile. I am really looking forward to implementing these new ideas. For that I thank you! I'm a rather intermediate Ruby programmer but if anyone would like to check out rr they can at my blog. Here is a link to the most recent article: http://bogojoker.com/weblog/2008/01/01/rr-11-in-place-edits-and-multiple-files/ -- Posted via http://www.ruby-forum.com/.