Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Matching a pattern in python

pattern = "F-x-([EK])-x-S-([GT])-R-T"
pattern=pattern.replace("-","")
pattern=pattern.replace("x","[GPAVLIMCFYWHKRQNEDST]")
count=0

for sequence in source:
    count += 1
    sequence=sequence.replace(" ","")
    result = re.finditer(pattern, sequence)
    print(">sequence ",count)
    print(sequence)
    for match in result:
        print("found ",match.group()," at position",match.span()," third position =", match.group(2))
Comment

PREVIOUS NEXT
Code Example
Python :: python object creation 
Python :: shallow copy deep copy python 
Python :: how to duplicate a row in python 
Python :: cannot unpack non-iterable int object when using python dicitonary 
Python :: python dictionary accessing an element 
Python :: python round 
Python :: python code checker 
Python :: python own function and map function 
Python :: reverse the string in python 
Python :: python create nested dictionary 
Python :: pandas count distinct values in column 
Python :: what is heapq in python 
Python :: how to run multiple python files one after another 
Python :: what does filename = path(file).stem python 
Python :: drop null values in dataframe 
Python :: iterating over lines in a file 
Python :: how to make a calcukatir un python 
Python :: parce que in english 
Python :: decoding 
Python :: get category discord.py 
Python :: time series python 
Python :: numpy vs tensorflow 
Python :: python tkinter get entry text 
Python :: from django.urls import path 
Python :: pygame screen 
Python :: how to bubble sort a 2d array in python 
Python :: count variable in class python 
Python :: EJERCICIOS DE FOR Y WHILE en python 
Python :: pandas Timedelta to postgres 
Python :: python gmail 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =