(' '' - 'areacodemainnumber mo groups(print(areacode print(mainnumber - since mo groups(returns tuple of multiple valuesyou can use the multiple-assignment trick to assign each value to separate variableas in the previous areacodemainnumber mo groups(line parentheses have special meaning in regular expressionsbut what do you do if you need to match parenthesis in your textfor instancemaybe the phone numbers you are trying to match have the area code set in parentheses in this caseyou need to escape the and characters with backslash enter the following into the interactive shellphonenumregex re compile( '(\(\ \ \ \)(\ \ \ -\ \ \ \ )'mo phonenumregex search('my phone number is ( - 'mo group( '( )mo group( ' - the \and \escape characters in the raw string passed to re compile(will match actual parenthesis characters in regular expressionsthe following characters have special meaningsif you want to detect these characters as part of your text patternyou need to escape them with backslash\\\\\\\\\\\\\make sure to double-check that you haven' mistaken escaped parentheses \and \for parentheses and in regular expression if you receive an error message about "missing )or "unbalanced parenthesis,you may have forgotten to include the closing unescaped parenthesis for grouplike in this examplere compile( '(\(parentheses\)'traceback (most recent call last)--snip-re errormissing )unterminated subpattern at position the error message tells you that there is an opening parenthesis at index of the '(\(parentheses\)string that is missing its corresponding closing parenthesis pattern matching with regular expressions