in reply to Analysis of Regular Expressions
Three possibilities on creating a regex-generality-rating come into my mind:
1. would be easy to implement (generate all strings, match) - but is probably much too slow (just counting the letters and numbers would
give you 26+26+10 different characters at each position of your string ...
... so this approach is not feasible :-(
2. is more tricky - you need to analyze the regex, but this is possible (see the previous answers, or here for some tools for this.)
I would then calculate two ratings for this and combine them in a suitable way (however suitable looks like ;-)
you might overcome this by adding "^.*" and ".*$" to your regexes before analysis ...Hi = ^.*Hi = ^.*.?Hi = .*Hi.* = ^.*.?.*Hi.*$
3. If I had the task you describe, I'd first check my possible input-regexes (maybe most of them are just simple?) and check if there is an issue if some are not ordered correctly. Probably it is possible to create a simplified formula that works well in most cases ...
HTH, Rata (very interested on how you sort this problem out!)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Analysis of Regular Expressions
by JavaFan (Canon) on Mar 17, 2010 at 10:59 UTC | |
by ikegami (Patriarch) on Mar 17, 2010 at 20:39 UTC | |
Re^2: Analysis of Regular Expressions
by PetaMem (Priest) on Mar 17, 2010 at 17:16 UTC | |
by Ratazong (Monsignor) on Mar 18, 2010 at 07:02 UTC | |
Re^2: Analysis of Regular Expressions
by LanX (Saint) on Mar 17, 2010 at 13:47 UTC |