Matching G in ‘Reference: G. ‘ using regular expression
I tried using this but error still occur
refresidue = re.compiler(r'(s/Reference: \ //n)')
Any other suggestions as I’m quite new in this. Any help is most appreciated.
‘Reference: G. ‘ reference can be either A,C,G or T
I’m sorry about the confusion – what i would like to have is that the output only prints out the characters (A,C,G,T) instead of Reference: .
This is my code
refresidue = re.compiler(r'(s/Reference: \ //n)’)
a_matchref = refresidue.search(row[2])
if a_matchref is not None:
a_matchref = a_matchref.group(1)
You’re mixing regex syntax from JavaScript (or some other regex flavor) and Python; and the regex itself is also quite strange. Also,
re.compile()compiles a regex, it doesn’t match it to anything.Assuming you want to match a single alphanumeric character after the text
Reference:, try the following: