Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
^P(\d+([,\.]\d+)?Y)?(\d+([,\.]\d+)?M)?(\d+([,\.]\d+)?D)?(T(\d+([,\.]\d+)?H)?(\d+([,\.]\d+)?M)?(\d+([,\.]\d+)?S)?)?$
/
gm
Unit Tests
P1Y
→ regex does match
PT35M
→ regex does match
P12MT32M
→ regex does match
P35S
→ regex does not match
P5W
→ regex does match
PT0.5H
→ regex does match
P1
→ regex does not match
T32M
→ regex does not match