Accueil
Rechercher:
sur developpez.com sur les forums
Forums | Tutoriels | F.A.Q's | Participez | Hébergement | Contacts
Accueil Conception Java DotNET Visual Basic  C  C++ Delphi Eclipse MS-Office SQL & SGBD Oracle  4D  Business Intelligence
Club Emploi Blogs   TV   Dév. Web PHP XML Python Autres 2D-3D-Jeux Sécurité Windows Linux PC Mac
FORUM PYTHON F.A.Q PYTHON TUTORIELS PYTHON SOURCES PYTHON OUTILS PYTHON LIVRES PYTHON
7.7. Summary

7.7. Summary

This is just the tiniest tip of the iceberg of what regular expressions can do. In other words, even though you're completely overwhelmed by them now, believe me, you ain't seen nothing yet.

You should now be familiar with the following techniques:

  • ^ matches the beginning of a string.
  • $ matches the end of a string.
  • \b matches a word boundary.
  • \d matches any numeric digit.
  • \D matches any non-numeric character.
  • x? matches an optional x character (in other words, it matches an x zero or one times).
  • x* matches x zero or more times.
  • x+ matches x one or more times.
  • x{n,m} matches an x character at least n times, but not more than m times.
  • (a|b|c) matches either a or b or c.
  • (x) in general is a remembered group. You can get the value of what matched by using the groups() method of the object returned by re.search.

Regular expressions are extremely powerful, but they are not the correct solution for every problem. You should learn enough about them to know when they are appropriate, when they will solve your problems, and when they will cause more problems than they solve.

 

Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have two problems.

 
--Jamie Zawinski, in comp.emacs.xemacs  
Responsable bénévole de la rubrique Python : Guillaume Duriaud - Contacter par EMail :
Vos questions techniques : forum d'entraide Python - Publiez vos articles, tutoriels et cours
et rejoignez-nous dans l'équipe de rédaction du club d'entraide des développeurs francophones
Nous contacter - Copyright © 2000-2008 www.developpez.com - Legal informations.