python3 advanced regular expression re module

re module

1.match()method:

  Determine whether it matches, if the match is successful, return an Matchobject, 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  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324838274&siteId=291194637