擅长:python、mysql、java
<pre><code>import re
arrs = [
'1231234567-1234567',
'123-12345671234567',
'-123-1234567-1234567',
'12312345671234567',
'123-1234567-1234567',
]
for t in arrs:
print(t,' =>',end=' ')
if re.match(r'\d{3}\-\d{7}\-\d{7}',t):
print('Correct')
else:
print('Something is wrong!')
</code></pre>
<p>结果:</p>
<pre><code>1231234567-1234567 => Something is wrong!
123-12345671234567 => Something is wrong!
-123-1234567-1234567 => Something is wrong!
12312345671234567 => Something is wrong!
123-1234567-1234567 => Correct
</code></pre>