| reconvert | index /usr/lib/python1.6/reconvert.py |
Convert old ("regex") regular expressions to new syntax ("re").
When imported as a module, there are two functions, with their own
strings:
convert(s, syntax=None) -- convert a regex regular expression to re syntax
quote(s) -- return a quoted string literal
When used as a script, read a Python string literal (or any other
expression evaluating to a string) from stdin, and write the
translated expression to stdout as a string literal. Unless stdout is
a tty, no trailing
is written to stdout. This is done so that it
can be used with Emacs C-U M-| (shell-command-on-region with argument
which filters the region through the shell command).
No attempt has been made at coding for performance.
Translation table...
\( ( (unless RE_NO_BK_PARENS set)
\) ) (unless RE_NO_BK_PARENS set)
\| | (unless RE_NO_BK_VBAR set)
\< (not quite the same, but alla...)
\> (not quite the same, but alla...)
\` \A
' \Z
Not translated...
.
^
$
*
+ (unless RE_BK_PLUS_QM set, then to \+)
? (unless RE_BK_PLUS_QM set, then to \?)
\B
\w
\W
... \9
Special cases...
Non-printable characters are always replaced by their 3-digit
escape code (except ,
,
, which use mnemonic escapes)
Newline is turned into | when RE_NEWLINE_OR is set
XXX To be done...
[...] (different treatment of backslashed items?)
[^...] (different treatment of backslashed items?)
^ $ * + ? (in some error contexts these are probably treated differently)
DD \DD (in the regex docs but only works when RE_ANSI_HEX set)
| Modules | ||||||
| ||||||
| Functions | ||
| ||
| Data | ||
| RE_ANSI_HEX = 64 RE_BK_PLUS_QM = 4 RE_CONTEXT_INDEP_OPS = 32 RE_NEWLINE_OR = 16 RE_NO_BK_PARENS = 1 RE_NO_BK_VBAR = 2 RE_NO_GNU_EXTENSIONS = 128 RE_SYNTAX_AWK = 35 RE_SYNTAX_EGREP = 51 RE_SYNTAX_EMACS = 0 RE_SYNTAX_GREP = 20 RE_TIGHT_VBAR = 8 __file__ = '/usr/lib/python1.6/reconvert.pyc' __name__ = 'reconvert' mastertable = {'\011': r'\t', '\012': r'\n', '\015': r'\r', '(': r'\(', ')': r'\)', r"\'": r'\Z', r'\(': '(', r'\)': ')', r'\<': r'\b', r'\>': r'\b', ...} | ||