regex - Reversing a regular expression in Python -


I want to reverse a regular expression i.e. Have given a regular expression, I want to produce the any string that will match that reggae.

I know how to use a finite state machine from a theoretical computer science background, but I just want to know if someone has already written a library to do this. :)

I am using Python, so I like a Python Library.

To repeat, I want to simply a string regex. Things like "." Or ". *" Will match an infinite amount of strings to Reggae, but I do not care about all the options.

I'm only ready for this library only to work on a certain subset of regex.

Anyone else has a similar (duplicate) question, and I'm a little helper

This includes a method, xeger () allows you to create a string:

  & gt; & Gt; & Gt; Import rstr & gt; & Gt; & Gt; Rstr.xeger (r '[AZ] \ d [AZ] \ d [AZ] \ d') u'M5R 2W4 ' 

Right now, it works with the most basic regular expressions But I'm sure it can be improved.


Comments