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

Oleg Broytmann phd at phd.pp.ru
Thu Jun 20 06:54:53 EDT 2002


On Thu, Jun 20, 2002 at 10:34:06AM +0000, Fredrik Lundh wrote:
> 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?

   IP address (but it is required to test that every nibble is < 256)
   URL
   e-mail address (yes, I know very good how hard it is)
   identificator (letters+digits, starting with a letter)
   empty line
   line consisted only with whitespaces
   comment line, starting with #, may have whitespaces before #

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list