嗨,我正在从文件中读取一行,我需要获取其中最长的标识符,例如在该行中
MY_Variable = Some_Variable+New_Variable;
在上面的行中,我需要获取“Some_Variable”。我尝试使用下面的代码,但我得到的结果为
Some_Variable+New_Variable
我试过这个
if(re.search('[a-zA-Z]', Line_Read)): ## To check whether line has identifier or not
if(len(max(Line_Read.split(), key=len))>32): ## length of the longest string is greater than 32 or not?
print max(Line_Read.split(), key=len) ## printing the identifier
请帮忙。谢谢