re module
1.match()
method:
Determine whether it matches, if the match is successful, return an Match
object, otherwise returnNone
#Example 1:
test1= ' 012-12345678 ' if re.match(r ' ^\d{3}\-\d{3,8}$ ' ,test1): print ( 'yes ' ) else : print ( ' failed ' )
#Output #
yes #Description
: ^ means start matching from the beginning of the line, $ means the end of the line, match 3 numbers plus - then 3-8 numbers