UVa 325 Identifying Legal Pascal Real Constants Solution

import re
def Main():
    s=input()
    patt=re.compile(r'^\s*[+-]?(\d+\.\d+|\d+[eE][+-]?\d+|\d+\.\d+[e|E][+-]?\d+)\s*$')
    while s!='*':
        if patt.search(s) is not None:
            print(s.strip()+" is legal.")
        else:
            print(s.strip()+" is illegal.")
        s=input()
if __name__=="__main__":
    Main()

Comments