Match Substring Python Function Syntax