Useful RE patterns (was: Variable Interpolation - status of PEP 215)

Fredrik Lundh fredrik at pythonware.com
Thu Jun 20 06:34:06 EDT 2002


I wrote:

> # match $$ and $var and ${var}
> _dosub = sre.compile(r'\$(?:\$|(\w+)|\{([^}]*)\})').sub

As part of the python-dev discussion, I mentioned that it might
be a good idea to add a couple of standard RE patterns to the
standard library, e.g. to match things like integer literals, IP-
numbers (etc).

If I were to add a dozen (or so) patterns to the (S)RE module,
what should I pick?  What patterns do you find yourself using
over and over again?

</F>





More information about the Python-list mailing list