5

Possible Duplicates:
Random Text generator based on regex
Using Regex to generate Strings rather than match them

Hi, I need a matches generator for my regular expressions. E.g. for input like:

[A-Z]+[0-9]?

I get output:

FDLJUIOAF
LFDSJKHI8
B
IJKL5

And so on. I need this to show client what commands are currently supported so he can tell me what he wants to be added.

Does anyone know if there are such services?

Community
  • 1
  • 1
Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115
  • 1
    Ah, cool - you want to run a regexp engine IN REVERSE! Do you want to generate all possible cases (not always possible), or just all cases up to a particular length, or just N random cases which work? – Alex Brown Jan 28 '10 at 14:33
  • There are some similar questions here: * http://stackoverflow.com/questions/22115/using-regex-to-generate-strings-rather-than-match-them * http://stackoverflow.com/questions/205411/random-string-that-matches-a-regexp * http://stackoverflow.com/questions/274011/random-text-generator-based-on-regex – Rorick Jan 28 '10 at 14:35

2 Answers2

0

Problem is - for some expressions you can have an unlimited number of strings that match it. You could brute-force all strings of length 5, but that is very computationally intensive already. I am of the opinion that a human can do a better REPRESENTATIVE job.

Hamish Grubijan
  • 10,562
  • 23
  • 99
  • 147
0

Here's a microsoft tool which does exactly this job:

msdn.microsoft.com : The regular expression generator

Note that the dialect may be different from the one you are using - check carefully.

Alex Brown
  • 41,819
  • 10
  • 94
  • 108
  • This seems to be awfully complex to set up. Not really a nice, small tool, apparently. – Joey Jan 28 '10 at 14:46