You are viewing a single comment's thread. Return to all comments →
regex_pattern = r"^(M{0,3})(C{0,3}|CD|D|DC|DCC|DCCC|CM)(X{0,3}|XL|L|LX|LXX|LXXX|XC)(I{0,3}|IV|V|VI|VII|VIII|IX)$"
import re print(str(bool(re.match(regex_pattern, input()))))
Seems like cookies are disabled on this browser, please enable them to open this website
Validating Roman Numerals
You are viewing a single comment's thread. Return to all comments →
regex_pattern = r"^(M{0,3})(C{0,3}|CD|D|DC|DCC|DCCC|CM)(X{0,3}|XL|L|LX|LXX|LXXX|XC)(I{0,3}|IV|V|VI|VII|VIII|IX)$"
import re print(str(bool(re.match(regex_pattern, input()))))