RE strings (was: Variable Interpolation - status of PEP 215)
Fredrik Lundh
fredrik at pythonware.com
Thu Jun 20 06:39:38 EDT 2002
and while I'm at it:
> # match $$ and $var and ${var}
> _dosub = sre.compile(r'\$(?:\$|(\w+)|\{([^}]*)\})').sub
how about adding "re" strings (where the "e" tells Python
to run the string through the RE compiler):
re"[-+]\d+"
re"(\d+)\.(\d+)\.(\d+)\.(\d+)"
_dosub = re'\$(?:\$|(\w+)|\{([^}]*)\})'.sub
ishex = re'0[xX][\dA-Fa-f]'.match
# etc
(or maybe a ".re" method that does the same thing, but
with an optional flag argument ?)
</F>
More information about the Python-list
mailing list