yes.
I need to use word1 and word5 as start and end of this pattern, but
there may be other word1...word5 patterns which don't include
word3/word4 - I don't need them.
actually, I used "word1.*word2(.*?)word3.*word4.*word5"
yes.
Okay: As I wrote earlier, "You have my sympathies."
Then you should, before haring off after efficiencies that may
turn out to be meaningless. People have made studies of how good
programmers are at predicting which pieces of their programs will
take the most time, and study after study has shown that even the
Great Grand Gurus are dismal failures at it. Measure, *then* worry
about efficiency -- because if you don't, chances are better than
even that you'll be worrying about something irrelevant.
Idle Question #1: How much time have you spent writing these
messages to Usenet and contemplating the answers?
Idle Question #2: How much faster must you make the pattern-
matching merely to break even on the time already devoted to #1?