Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Python

r"
((?P<fulldate>(?P<date>(\d{4}-\d{2}-\d{2}))T(?P<time>(\d{2}:\d{2}:\d{2}(?:\.\d+)?)))(?P<tz>(Z|[\+-]\d{2}:\d{2})?))
"
gm

Description

Parses ISO date like: 2021-01-19T15:21:32.59+02:00

and returns these named groups:

  • fulldate (full date and time)
  • date (2021-01-19)
  • time (15:21:32.59)
  • tz (+02:00)
Submitted by Fabio Rotondo (fsoft) - 3 years ago