This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Special symbols [ ] + % Regular Expressions a- a a* - a repeated 0 or more times a+ - a repeated 1 or more times a? a 0 or 1 time, so a is optional ^ - match at the beginning of the string $ - match at the end of the string . matches anything [abc] match a, b, or c [a-z] match any character from a to z [^a] match any character but a More on regular expressions | - or \b - word boundary \s - whitespace character \d match any digit When using backslashes must use r in front of string Regular expressions with re import re re.sub() substitute re.compile() create a pattern re.findall() See examples...
View Full Document
This document was uploaded on 01/17/2012.
- Fall '09