"be consistent" | |
PerlMonks |
RE: RE (tilly) 1: Numeric list to optimised regexpby ncw (Friar) |
on Sep 07, 2000 at 12:54 UTC ( [id://31368]=note: print w/replies, xml ) | Need Help?? |
I didn't realise anyone had had a go at this sort of thing
already, though it is inevitable really! I'll anwser tilly's question with an example:- My code gives (for the list 1..255)
Whereas your code gives My aim was to get rid of as many alternations as possible (which are slow) and turn them into character classes (which are fast). I wanted also to factor the regexp as much as possible. If you change my code replacing all \d's with \w or whatever it should work fine for any list of words, but I designed and tested it with numeric lists in mind. My first attempt at this problem used a trie like data structure but I abandonded it once I had the idea of using backtracking regexps - the irony of using regexps to optimise regexps was irresistable!
In Section
Craft
|
|