I am learning regular expression through Al Sweigart\'s automate the boring stuff course on udemy, lesson 29. I get an error saying \"unbalanced parenthesis at position 414 (lin
You need to fix this line (\d{2,5}))? # extension number part (optional)
. Clearly it needs to either add/remove a parenthesis.
Changing that line to (\d{2,5})?
will fix the unbalanced parenthesis
error.
Please note the unbalance that will probably give you an idea how to fix it.
# Types of number 415-555-0000, 555-0000, (415) 555-0000, 555-0000 ext 12345,
# ext. 12345, x12345
( # (1 start)
( # (2 start), area code (optional)
( \d\d\d ) # (3)
| ( \( \d\d\d \) ) # (4)
)? # (2 end)
( \s | - ) # (5), first separator
\d\d\d # first 3 digits
- # separator
\d\d\d\d # last 4 digits
( # (6 start), extension word part (optional)
( # (7 start)
ext
( \. )? # (8)
\s
) # (7 end)
| x
) # (6 end)
( \d{2,5} ) # (9), extension number part (optional)
)? # (1 end)
= ) <-- Unbalanced ')'