- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to match pattern over multiple lines in Python?
The re.DOTALL flag tells python to make the ‘.’ special character match all characters, including newline characters.
import re paragraph = \ ''' This is a paragraph. It has multiple lines. ''' match = re.search(r'<p>.*</p>', paragraph, re.DOTALL) print match.group(0)
This is a paragraph. It has multiple lines.
- Iterate over lines from multiple input streams in Python
- Regex to match lines containing multiple strings in Java
- How to write multiple lines in text file using Python?
- How can we print multiple blank lines in python?
- Use Pattern class to match in Java
- Python program to show diamond pattern with 2n-1 lines
- How to use regular expression in Java to pattern match?
- How to print multiple blank lines in C#?
- How can multiple lines be visualized using Bokeh Python?
- Python program to iterate over multiple lists simultaneously?
- How do we use file.readlines() to read multiple lines using Python?
- How to write a Python regular expression to match multiple words anywhere?
- How to display multiple lines of text in Tkinter Label?
- How to create multiple regression lines using ggplot2 in R?
- How to print pattern in Python?