re.findall() returns extra data when using optionals in between Regex expressions
<p>I seem to be getting additional variables that I do not want stored into this array. What I expected to return after running the following code is this </p>

<pre><code>[('999-999-9999'), ('999 999 9999'), ('999.999.9999')]
</code></pre>

<p>However what I end up with is the following</p>

<pre><code>[('999-999-9999', '-', '-'), ('999 999 9999', ' ', ' '), ('999.999.9999', '.', '.')]
</code></pre>

<p>The following is what I have</p>

<pre><code>teststr = '''
    Phone: 999-999-9999,
           999 999 9999,
           999.999.9999
'''
phoneRegex = re.compile(r'(\d{3}(-|\s|\.)\d{3}(-|\s|\.)\d{4})')

regexMatches = phoneRegex.findall(teststr)
print(regexMatches)
</code></pre>

<p>Turn the inner capturing groups to non-capturing groups.</p>

<pre><code>(?:-|\s|\.)
</code></pre>

<p>or</p>

<pre><code>[-\s.]
</code></pre>

<p>Example:</p>

<pre><code>&gt;&gt;&gt; import re
&gt;&gt;&gt; teststr = '''
    Phone: 999-999-9999,
           999 999 9999,
           999.999.9999
'''
&gt;&gt;&gt; re.findall(r'\b(\d{3}[-.\s]\d{3}[.\s-]\d{4})\b', teststr)
['999-999-9999', '999 999 9999', '999.999.9999']
&gt;&gt;&gt; 
</code></pre>

python