RegEx Flashcards

Learn about regular expressions and using them in Python

1
Q

How to find pattern in Python?

A
  1. Import re
  2. compile pattern
  3. match/search
  4. Used recieved re.Match object
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to compile pattern?

A

re.compile(r’[0-9]’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What re.match and re.search returns?

A

None (if no match) re.Match object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Important re.Match object attributes and methods

A

.span() returns tuple with match position

.string is matched string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly