Python "Invalid Syntax Error" With Regular Expression for Phone
<p>I'm trying to create a phone regex, based on <a href="http://stackoverflow.com/a/123666/773210">a pattern provided in another stack overflow question.</a></p>

<p>This is the syntax I used to create it in Python:</p>

<pre><code>def phoneRegex = r'^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$'
</code></pre>

<p>However, when running this code I get the error:</p>

<pre><code>^ SyntaxError: invalid syntax
</code></pre>

<p>What am I doing wrong?  Do I need to escape the characters somehow?</p>
