Community Patterns

Community Library Entry

0

Regular Expression
Created·2019-11-07 17:03
Flavor·PCRE (Legacy)

/
^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$
/
gm
Open regex in editor

Description

Without lookaround, this regular expression also accepts P and PT as valid duration strings. If your library supports lookaround, I recommend that you use Full ISO 8601 Duration with lookaround (also in the library) instead, which will also reject P and PT.

Submitted by anonymous