4.3 reconvert -- Convert regular expressions from regex to re form

This module provides a facility to convert regular expressions from the syntax used by the deprecated regex module to those used by the newer re module. Because of similarity between the regular expression syntax of sed(1) and emacs(1) and the regex module, it is also helpful to convert patterns written for those tools to re patterns.

When used as a script, a Python string literal (or any other expression evaluating to a string) is read from stdin, and the translated expression is written to stdout as a string literal. Unless stdout is a tty, no trailing newline is written to stdout. This is done so that it can be used with Emacs C-U M-| (shell-command-on-region) which filters the region through the shell command.

See Also:

Mastering Regular Expressions
Book on regular expressions by Jeffrey Friedl, published by O'Reilly. The second edition of the book no longer covers Python at all, but the first edition covered writing good regular expression patterns in great detail.



Subsections
See About this document... for information on suggesting changes.