MatchesXsYearMonthDuration🔗

Type: Pattern verification
Check that text conforms to the pattern of an xs:yearMonthDuration.
text🔗
Text to be checked
Return🔗
True if the text conforms to the pattern

Code

yearMonthDurationRep = (
    '-?P((([0-9]+Y)([0-9]+M)?)|([0-9]+M))'
)
pattern = (
    f'^{yearMonthDurationRep}$'
)
return match(
    pattern,
    text
) is not None