MatchesXsYearMonthDuration🔗
Check that
text conforms to the pattern of an xs:yearMonthDuration.
Code
year_month_duration_rep = r"-?P((([0-9]+Y)([0-9]+M)?)|([0-9]+M))"
pattern = f"^{year_month_duration_rep}$"
return match(pattern, text) is not None