0

This should be easy for those who know regex but for some reason I can not understand why the pattern does not match:

p1 = re.compile('''(\d{2}       # Matches two digits -- e.g: 13
                \s*            # Matches any number of spaces
                -              # Matches the literal character -
                \s*            # Matches any number of spaces
                \d{2}          # Matches two digits -- e.g: 06
                \s*            # Matches any number of spaces
                -              # Matches the literal character -
                \s*            # Matches any number of spaces
                \d{4})          # Matches four digits -- e.g: 2017''', re.VERBOSE)


txt3 = 'date   13 – 06 - 2017.   '

p1.findall(txt3)
[]

Can you explain the failure? How the code should be corrected?

user8270077
  • 3,589
  • 5
  • 41
  • 90

0 Answers0