正则匹配问题
基因测序法Bacillus hisashii(NR144578.1)99.789%基因测序法Bacillus hisashii;NR144578.2;99.7%
基因测序法Bacillus hisashii NR144578.1 100%
基因测序法Bacillus sp.(NR144578.1)99.739%
基因测序法Bacillus hisashii;NR144578.1;99.743%
匹配以上字符串中的英文名称和最终的百分比,我用的正则是
r'基因测序法(+ +).*(\d+\.?\d+)%'
总是出错,求大神指点,不胜感激!
import re
st1 = '''
基因测序法Bacillus hisashii(NR144578.1)99.789%
基因测序法Bacillus hisashii;NR144578.2;99.7%
基因测序法Bacillus hisashii NR144578.1 100%
基因测序法Bacillus sp.(NR144578.1)99.739%
基因测序法Bacillus hisashii;NR144578.1;99.743%
'''
result = re.findall(r'法(.*?).NR.*?[; ;\)](.*?)%', st1)
print(result)
页:
[1]