* Ulrik Petersen <[EMAIL PROTECTED]> [2006-06-25 17:55]:
> 5) Use the function with the regex '[spqd]' to search for words
> containing the letters "s", "p", "q", OR "d".  Doing it for all
> letters (AND) may be doable with a single regex,

It is doable with an NFA engine like PCRE, but it’s complicated
to express and will incur so much backtracking that it’ll run
much slower than doing four separate matches.

With DFA engine such as egrep’s you can’t express it in a single
pattern at all.

For ultimate performance on strings, you’ll need to walk the
string using a loop in a machine-oriented language like C and
check characters directly.

If you need to go even faster, then you’ll need an inverted
index on letters for the whole dataset.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

Reply via email to