RegEx Flashcards
Learn about regular expressions and using them in Python
1
Q
How to find pattern in Python?
A
- Import re
- compile pattern
- match/search
- Used recieved re.Match object
2
Q
How to compile pattern?
A
re.compile(r’[0-9]’)
3
Q
What is a difference between match and search for pattern?
A
match compares beggining of a string and search finds pattern in whole string
4
Q
What re.match and re.search returns?
A
None (if no match) re.Match object
5
Q
Important re.Match object attributes and methods
A
.span() returns tuple with match position
.string is matched string