Explain the code

Can someone please explain the pattern given in match() function.

import re
li=['9999999999','999999-999','99999x9999']
for val in li:
 if re.match(r'[8-9]{1}[0-9]{9}',val) and len(val) == 10:
     print 'yes'
 else:
     print 'no'


Output:
yes
no
no

The regular expression

[8-9]{1}[0-9]{9}

Says 1 occurrence of any digit from 8 to 9, followed by 9 occurrences of any digit from 0 to 9.

[ ] tells what characters to look for
{ } - tells the count of those characters

You can learn more about regex here.

© Copyright 2013-2019 Analytics Vidhya