"<>THIS is the place to stay at when visiting the historical area of Seattle.
Your right on the water front near the ferry's and great sea food hotel.
The breakfast was great. <>"
Above is my sample text. I want to print the strings fall in between <> & <>. I want my output to be free of new line character \n, like this:
THIS is the place to stay at when visiting the historical area of Seattle. Your right on the water front near the ferry's and great sea food hotel.The breakfast was great.
I have tried the following piece of code:
import re
pattern = re.compile(r'\<>(.+?)\<>',re.DOTALL|re.MULTILINE)
text = """<>THIS is the place to stay at when visiting the historical area of Seattle.
Your right on the water front near the ferry's and great sea food hotel.
The breakfast was great.
<>"""
results = pattern.findall(text)
print results
But I am getting results like this :
["THIS is the place to stay at when visiting the historical area of Seattle.\n\nYour right on the water front near the ferry's and great sea food hotel.\n\nThe breakfast was great.\n"]
But I don't want any new line characters in my resulting string.
.replace("\n", "")on each found match. See ideone.com/2i5Rl8