We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Validating Roman Numerals
Validating Roman Numerals
Sort by
recency
|
201 Discussions
|
Please Login in order to post a comment
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()))))
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()))))
Regular Expression for this problem