我有一个字符串,我想提取介于 "" X "" 两个括号之间的 exon_number
我使用 re.search 来查找“exon_number”的出现,但我不想在最终输出中包含字符串 exon_number
例子:
temp_ID = []
k = '"gene_id ""XLOC_000001""; transcript_id ""TCONS_00000001""; exon_number ""1""; oId ""CUFF.17.1""; tss_id ""TSS1"";"'#input string
temp_ID.append((re.search(r'(exon_number\s""\d"")',k).group(1)))
print temp_ID
>['exon_number ""2""']
desired_output = ['2']
我希望输出只是两者之间的值," "
因为它可以是一位数/两位数,所以我无法选择 [-3] 位置
让我知道我是否需要以不同的方式澄清