Regex Flashcards

1
Q

Explain the meaning of the quantifiers: *, +, ?, {}

A
  • : 0 or many
    + : 1 or many
    ? : 0 or 1
    {n} : n times
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the wildcard do? What is its symbol?

A

. : any character is matched

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

Explain how groups work, and how to implement them?

A

(aa|bb) matches aa or bb

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

What does the following statement mean: [a-z0-9]*

A

lowercase letters or digits, 0 or many

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

What does the ^ mean in [^a]

A

anything but a

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

How would you get your matches as an iterable?

A

p = re.compile(‘[…]’)

p.finditer(document)

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