good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Most specific patternby GrandFather (Saint) |
on Jun 30, 2005 at 20:46 UTC ( [id://471470]=note: print w/replies, xml ) | Need Help?? |
If you can calculate the fitness at run time, then try all of the regex's and choose the match which matches using fewest wildcard matched characters. Are matches using a character set a lesser evil than those using .? Probably it's a function of the number of different characters that could have matched at each character location. The fitness should also be modified by providing some weighting for alternate matches. Would you need to account for backtracking too? Perl is Huffman encoded by design.
In Section
Seekers of Perl Wisdom
|
|