Python Check For Pattern In String Theory