[Tutor] regex problem with colon

Tim Johnson tim at johnsons-web.com
Fri Aug 7 02:47:39 CEST 2009


using python 2.5.
I'm having a problem with including a colon as part of a substring
bounded by whitespace or beginning of line.
Here's an example:
p = re.compile(r'\bcc:\b',re.IGNORECASE)
>>> res = p.findall('malicious cc: here CC: there')
>>> res
[]
## Darn! I'd hope that the 'cc:' and 'CC:' substrings would be
found. So how to compose the expression correctly?
TIA
-- 
Tim 
tim at johnsons-web.com
http://www.akwebsoft.com


More information about the Tutor mailing list