5 ms·
Can you give me a use case for this? It is not very hard to do, given that random matches are already being generated, but I'm skeptical of its usefulness.
by tsergiu 13y ago
Can you give me a use case for this? It is not very hard to do, given that random matches are already being generated, but I'm skeptical of its usefulness.
- bane 13y agoUse-cases: 1) regex search against an indexed database: use a regex to generate a search list, search a well indexed database with this list instead of linearly scanning data in the database with the regexes. AFAIK there's no way to index in a way that is regex friendly, only wildcard friendly...so most database systems that offer regex search just do a more traditional regex match against the contents of the table elements. In most cases, even searching tens of thousands of terms will be faster than the typical regex alternative. 2) education - you might use the generated lists while learning regexes to verify that you've accounted for various edge cases 3) data verification - you're using a regex to verify data, something is slipping through, see if it exists in the edge of generated matches (surprisingly common problem) 4) software testing & quality assurance. Define the possible inputs to a method via regex and generate all possible inputs instead of just testing at boundary conditions etc. 5) security/penetration testing, like #4 but to test cryptographic systems, passwords etc. there's tons more... Generating random members isn't sufficient as the runtime can grow extraordinarily long as you keep generating hoping you get all possible members, and you may not be certain when you can halt. Some tools like tempting, like Microsoft Research's Rex http://research.microsoft.com/en-us/projects/rex/ http://research.microsoft.com/en-us/projects/rex/ but the member list it generates is incomplete for example: ^(rich|richard|dick)( j\.)? th?om{1,2}[ae]s{1,2}[eo]n$ generates: "rich\sj.\sthommesson" "richard\sthomasen" "dick\stomasen" "rich\stommeson" "dick\sj.\stommassen" "dick\sj.\sthomessen" "dick\sthomessen" "rich\sthommeson" "richard\stommasen" "rich\sthomesen" which misses a whole host of other matches
- tsergiu 13y agoThanks for the feedback! I'll take this into account for future development plans.