May-27-2021, 05:01 PM
Hi,
Im trying to solve a problem using re module, and one of the requests is to find a string with the letters ATGC only in uppercase.
this is my code:
I've tried several things but none worked.
Appreciate any kind of help!
Im trying to solve a problem using re module, and one of the requests is to find a string with the letters ATGC only in uppercase.
this is my code:
def isVCF(file): num_format = re.compile(r"^chr(?:0?[1-9]|[1-9][0-9]|[MXY])\t0*[1-9][0-9]*\t[^\t]*(?:\t[ATCG]){2}\t") with open(file, "r+") as my_file: for line in my_file: if not num_format.match(line): return False return Trueand this is an example to a line:
Output:ChrX 74226540 T t 50 .
The problem is that its matching the lowercase "t" aswell and I only want it to find uppercase letters.I've tried several things but none worked.
Appreciate any kind of help!