Question 3
Back to Exercise
Why are regex patterns usually written as raw strings like r"\bword\b"?
- A So backslashes reach the regex engine unchanged instead of being treated as Python escapes Correct
- B Raw strings run faster
- C The re module accepts only raw strings
- D They make matching case-insensitive
Correct Answer: Option A
Without r, "\b" is a backspace character, so the pattern would not mean "word boundary".
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!