MatchesXsDecimal🔗

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

Code

digit = "[0-9]"
unsigned_no_decimal_pt_numeral = f"{digit}+"
no_decimal_pt_numeral = rf"(\+|-)?{unsigned_no_decimal_pt_numeral}"
frac_frag = f"{digit}+"
unsigned_decimal_pt_numeral = (
    rf"({unsigned_no_decimal_pt_numeral}\.{frac_frag}|\.{frac_frag})"
)
decimal_pt_numeral = rf"(\+|-)?{unsigned_decimal_pt_numeral}"
decimal_lexical_rep = f"({decimal_pt_numeral}|{no_decimal_pt_numeral})"

pattern = f"^{decimal_lexical_rep}$"
return match(pattern, text) is not None