You need Regular Expression
:
>>> import re
>>> re.sub('\nThis.*?ok','',a, flags=re.DOTALL)
' Example String'
More Related Contents:
- Turn the whole file uppercase
- Why isn’t it global?
- What is the purpose of the word ‘self’?
- How to compute the similarity between two text documents?
- Multiple Python versions on the same machine?
- pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
- Vectorized searchsorted numpy
- Plot two histograms on single chart with matplotlib
- Why does my Pandas DataFrame not display new order using `sort_values`?
- OperationalError: database is locked
- Python: dynamically create function at runtime
- Using pytest with a src layer
- How do I mention a user in discord.py?
- Converting a column within pandas dataframe from int to string
- Are strings cached? [duplicate]
- Decompile Python 2.7 .pyc [closed]
- Simpler way to draw a circle with tkinter?
- How to show a bar and line graph on the same plot
- “UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.” when plotting figure with pyplot on Pycharm
- Launch an IPython shell on exception
- How does reduce function work?
- matplotlib: how to draw a rectangle on image
- How to multiply individual elements of a list with a number?
- How do I align gridlines for two y-axis scales using Matplotlib?
- How to execute tests with selenium webdriver while browser is minimized
- How to move a no frame pygame windows when user click on it?
- Is there a benefit to defining a class inside another class in Python?
- Convert Python Opencv Image (numpy array) to PyQt QPixmap image
- Socket Programming Python: How to make sure entire message is received?
- Is there a way to take screenshot of a window in pyqt5 or qt5?