Reversing a regular expression in Python

Somebody else had a similar (duplicate?) question here, and I’d like to offer a little helper library for generating random strings with Python that I’ve been working on.

It includes a method, xeger() that allows you to create a string from a regex:

>>> import rstr
>>> rstr.xeger(r'[A-Z]\d[A-Z] \d[A-Z]\d')
u'M5R 2W4'

Right now, it works with most basic regular expressions, but I’m sure it could be improved.

Leave a Comment