I have a long file which follows some structure and I want to parse this file to extract an object called sample:
The file named paths_text.txt is like that:
/groups/cgsd/javed/validation_set/LeungSY_Targeted_SS-190528-01a/Clean/pfg001G_1_Clean.fastq.gz /groups/cgsd/javed/validation_set/LeungSY_Targeted_SS-190528-01a/Clean/pfg001G_2_Clean.fastq.gz /groups/cgsd/javed/validation_set/LeungSY_Targeted_SS-190528-01a/Clean/pfg001T_1_Clean.fastq.gz /groups/cgsd/javed/validation_set/LeungSY_Targeted_SS-190528-01a/Clean/pfg001T_2_Clean.fastq.gz My code runs fine like this:
import os os.chdir('/groups/cgsd/alexandre/python_code') import re with open('./src/paths_text.txt') as f: for line in f: sample = re.search(r'pfg\d+',line) print(sample) But when I search for underscore I get None as a result of my match, why?
import os os.chdir('/groups/cgsd/alexandre/python_code') import re with open('./src/paths_text.txt') as f: for line in f: sample = re.search(r'pfg\d+_',line) print(sample) https://stackoverflow.com/questions/65912347/python-regular-expression-search-not-finding-underscore-in-path January 27, 2021 at 11:05AM
没有评论:
发表评论