In python, I am looking for python code which I can use to create random data matching any regex. For example, if the regex is
\d{1,100}
I want to have a list of random numbers with a random length between 1 and 100 (equally distributed)
There are some 'regex inverters' available (see here) which compute ALL possible matches, which is not what I want, and which is extremely impracticable. The example above, for example, has more then 10^100 possible matches, which never can be stored in a list. I just need a function to return a match by random.
Maybe there is a package already available which can be used to accomplish this? I need a function that creates a matching string for ANY regex, not just the given one or some other, but maybe 100 different regex. I just cannot code them myself, I want the function extract the pattern to return me a matching string.
\d{1,100}the real example? Could you paste some that you work with in real? If the regex is not too fuzzy, you can generate random string that is close to the matching expression and discard it if it does not match.[A-C]{2}\d{2,20}@\w{10,1000}.\d*) would have an infinite number of possible lengths to chose from. But if you limit the regex syntax that's allowed a bit, it's probably doable.