Charlie Calvert on Elvenware

Writing Code and Prose on Computers

Elvenware

Regular Expressions in Python

    def parseFileName(self):
        name = "Android23.html"
        #p = re.compile("[A-za-z0-9]*[^.]([a-z])")
        p = re.compile("([^.]*)(.)([a-z]*)")        
        result = p.search(name)
        print result.groups()
        print result.group(0)
        print result.group(1)
        print result.group(2)
        print result.group(3)

This yields the following results:

('Android23', '.', 'html')
Android23.html
Android23
.
html