In this HackerRank Validating Roman Numerals problem solution You are given a string, and you have to validate whether it's a valid Roman numeral. If it is valid, print True. Otherwise, print False. Try to create a regular expression for a valid Roman numeral.

HackerRank Validating Roman Numerals in python problem solution

 HackerRank Validating Roman Numerals in python problem solution

import re
roman = input()
if re.search(r"^(I|V|X|L|C|D|M)+$", roman) == None:
    print("False")
elif re.search(r"(IIII|XXXX|CCCC|MMMM|VV|LL|DD)", roman) != None:
    print("False")
else:
    print("True")