Phd wrote: > I'm writing a regex related program that lets the user supplies the > regex definition. Is there an easy way to convert a string into a raw > string?
A raw string is a feature of the syntax of Python. Python gives you several ways to write strings: single quoted, double quoted, triple single, triple double, and raw versions of these. Once parsed from the source all of these simply become objects of type 'str'. The unicode modifier on a string does produce a different type of object internally (type 'unicode'), but the raw modifier does not. So, perhaps you would like to clarify what you really want to do? Perhaps give an example? If you are getting input from the user, then unless you are doing some processing on it to interpret escape sequences the chances are you already have what you need to use as a regular expression. If you *are* interpreting escape sequences then the answer is you need to not do that since the operation isn't really reversible. -- http://mail.python.org/mailman/listinfo/python-list