[Tutor] RegEx to search for the '$' symbol

kinuthiA muchanE muchanek at gmail.com
Wed Jun 11 13:29:31 CEST 2008



> ------------------------------
> 
> Message: 4
> Date: Wed, 11 Jun 2008 10:35:30 +0100 (GMT+01:00)
> From: "qsqgeekyogdty at tiscali.co.uk" <qsqgeekyogdty at tiscali.co.uk>
> Subject: [Tutor] RegEx to search for the '$' symbol
> To: tutor at python.org
> Message-ID: <26410943.1213176930690.JavaMail.root at ps35.mc.tiscali.sys>
> Content-Type: text/plain;charset="UTF-8"
> 
> Hi,
> Silly question but how do you use python's re module to find 
> dictionary items that contain the '$' symbol.
Hi, 
I no expert but here is my dime's worth...

> >>> import re
> >>> d = {'k':'$',1:'2','p':'$','j':'$dollar','l': 'dol$lar'}
> >>> for i in d.values():
> ...     re.findall(r'.*\$.*',i)
> ... 
> 
> []
> ['$']
> ['$dollar']
> ['dol$lar']
> []
> 
> NB:
> Empty matches are included in the result unless they touch the beginning of another match. 
> 
>  
> 
 Kinuthia...


> Thanks
> David
> 
> 
> 
> 



More information about the Tutor mailing list