Regex Python Search Algorithms Complexity