 <p>Decide which formats you want to recognize, then create a regular expression matching each one grouping the different parts of the number (like area code, prefix etc). Finally use a substitution to generate the canonical output you desire.</p> <p>Example:</p> <p>to match</p> <pre><code>xxx-xxx-xxxx -&gt; \d{3}-\d{3}-\d{4} (xxx) xxx-xxxx -&gt; \(\d{3}\) \d{3}-\d{4} 1-xxx-xxx-xxx -&gt; 1-\d{3}-\d{3}-\d{4} </code></pre> <p>This ignores rules that restrict prefix and area code (the US doesn't allow area codes or prefixes that being with 0 or 1). You could try and be super smart and create one regular expression that matches everything but you will end up with a jumbled mess that is impossible to modify instead you should OR the patterns together to make them easier to modify in the future. </p> <p>basic idea: </p> <pre><code>pattern = re.compile(r'\d{3}-\d{3}-\d{4}|\(\d{3}\) \d{3}-\d{4}|1-\d{3}-\d{3}-\d{4}') </code></pre> <p>with grouping added for canonical output </p> <pre><code>pattern = re.compile(r'(\d{3})-(\d{3})-(\d{4})|\((\d{3})\) (\d{3})-(\d{4})|1-(\d{3})-(\d{3})-(\d{4})') </code></pre> <p>then just run that against your inputs and for each phone number input you will have 3 matching groups, one for the area code, one for the prefix, and one for the suffix which you can output however you want. You need a basic understanding of regular expressions, but it shouldn't be too hard.</p>