<p>I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following:</p>

<ul>
<li><code>1-234-567-8901</code></li>
<li><code>1-234-567-8901 x1234</code></li>
<li><code>1-234-567-8901 ext1234</code></li>
<li><code>1 (234) 567-8901</code></li>
<li><code>1.234.567.8901</code></li>
<li><code>1/234/567/8901</code></li>
<li><code>12345678901</code></li>
</ul>

<p>I'll answer with my current attempt, but I'm hoping somebody has something better and/or more elegant.</p>

Here's my best try so far. It handles the formats above but I'm sure I'm missing some other possible formats.
```
```
^\d?(?:(?:[\+]?(?:[\d]{1,3}(?:[ ]+|[\-.])))?[(]?(?:[\d]{3})[\-/)]?(?:[ ]+)?)?(?:[a-zA-Z2-9][a-zA-Z0-9 \-.]{6,})(?:(?:[ ]+|[xX]|(i:ext[\.]?)){1,2}(?:[\d]{1,5}))?$
```
```