Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

regex python multiline

>>> import re
>>> rx_sequence=re.compile(r"^(.+?)

((?:[A-Z]+
)+)",re.MULTILINE)
>>> rx_blanks=re.compile(r"W+") # to remove blanks and newlines
>>> text="""Some varying text1
...
... AAABBBBBBCCCCCCDDDDDDD
... EEEEEEEFFFFFFFFGGGGGGG
... HHHHHHIIIIIJJJJJJJKKKK
...
... Some varying text 2
...
... LLLLLMMMMMMNNNNNNNOOOO
... PPPPPPPQQQQQQRRRRRRSSS
... TTTTTUUUUUVVVVVVWWWWWW
... """
>>> for match in rx_sequence.finditer(text):
...   title, sequence = match.groups()
...   title = title.strip()
...   sequence = rx_blanks.sub("",sequence)
...   print "Title:",title
...   print "Sequence:",sequence
...   print
...
Title: Some varying text1
Sequence: AAABBBBBBCCCCCCDDDDDDDEEEEEEEFFFFFFFFGGGGGGGHHHHHHIIIIIJJJJJJJKKKK

Title: Some varying text 2
Sequence: LLLLLMMMMMMNNNNNNNOOOOPPPPPPPQQQQQQRRRRRRSSSTTTTTUUUUUVVVVVVWWWWWW
Comment

PREVIOUS NEXT
Code Example
Python :: python pandas how to load csv file 
Python :: how to get started with python 
Python :: python accept user input 
Python :: csv python write 
Python :: server error 500 heroku django 
Python :: discord bot python on reaction 
Python :: rearrange list 
Python :: confusion matrix python 
Python :: get hwid python 
Python :: element not found selenium stackoverflow 
Python :: how to convert list to tensor pytorch 
Python :: ros python subscriber 
Python :: factorise expression python 
Python :: python pip fix 
Python :: python argparse 
Python :: how to make any player hit a ball using python turtle 
Python :: python program to give shop name 
Python :: python print time difference 
Python :: python print list items vertically 
Python :: ax set xtick size 
Python :: emacs region indent python 
Python :: python check string float 
Python :: append one column pandas dataframe 
Python :: how to split a string in python with multiple delimiters 
Python :: django read mesage 
Python :: suppress warning jupyter notebook 
Python :: django update increment 
Python :: previous value list loop python 
Python :: get every nth element in list python 
Python :: python for doing os command execution 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =