Ralph Shumaker wrote: > James G. Sack (jim) wrote: >> Ralph Shumaker wrote: >>.. >> In vim, I get the same one-line result with the vim command >> :/\(ada\|bub\|crc\|dod\).*\(ada\|bub\|crc\|dod\).*\(ada\|bub\|crc\|dod\).*\(ada\|bub\|crc\|dod\) > > *That* gets me what I was expecting (though I don't know why you have a > colon in front). I tried it with parentheses but didn't realize I had > to escape them (though I now understand the results of that attempt).
The colon is the vim prompt (helps see that I was speaking vimese) >.. > Actually, the ideal (as you correctly concluded) was to search for any > lines that contain at least one of each of the four search items, in > unknown sequence. (double "yuk!") > > I've been playing with regex, and it's been a while since I played with > grep. So with regex fresh (well, *more* fresh), I naturally thought of > it first... if you stop to think that the 're' in the middle of grep stands for Regular Expression, then you should have thought of grep first, eh? > .. Also, I kinda wanted to be able to see the line in context, > which grep precludes. But I found a different way to get what I want > with only *one* extra step. :-) As mentioned, the chained-grep approach may give false matches, depending on the actual search data. The painful enumeration of all the permutations may be the most reliable as well as the clearest expression of the problem logic. You can always write a script to generate the search pattern. I bet Stu could even whip one up as a vim macro. Probably not as easily done as in emacs (via elisp), I wager. Regards, ..jim -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list
