1. Computing

Python Regular Expression Examples: the Dollar Sign

By

Definition:
 >>> import re 
 >>> list = ['cat', 'car', 'cap', 'cab', 'cad', 'can', 'Katze', 'Auto', 
 'Deckel', 'Droschke', 'Flegel', 'Dose', 'CHAT', 'VOITURE', 'CHAPEAU', 
 'CABINE', 'DAO', 'BIDON'] 
 >>> y = re.compile('cap$') 
 >>> for x in list: 
 ...     if y.match(x): 
 ...             print x 
 ... 
 cap 
 >>> y = re.compile('D.*e$') 
 >>> for x in list: 
 ...     if y.match(x): 
 ...             print x 
 Droschke 
 Dose 
 >>> y = re.compile('.*e$') 
 >>> function(y) 
 Katze 
 Droschke 
 Dose 

Back to the main index of this glossary
  1. About.com
  2. Computing
  3. Python
  4. Regular Expressions
  5. Python RegEx Examples
  6. String Locations
  7. Python RegEx - Python Regular Expressions - Examples - the Dollar Sign

©2014 About.com. All rights reserved.