- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 find all adverbs and their positions in a text using python regular expression?
As per Python documentation
If one wants more information about all matches of a pattern than the matched text, finditer() is useful as it provides match objects instead of strings. If one was a writer who wanted to find all of the adverbs and their positions in some text, he or she would use finditer() in the following manner −
>>> text = "He was carefully disguised but captured quickly by police." >>> for m in re.finditer(r"\w+ly", text): ... print('%02d-%02d: %s' % (m.start(), m.end(), m.group(0))) 07-16: carefully 40-47: quickly
- Related Articles
- How to extract numbers from text using Python regular expression?
- How to extract date from text using Python regular expression?
- Find all the numbers in a string using regular expression in Python
- How to extract floating number from text using Python regular expression?
- How to extract email id from text using Python regular expression?
- How can I find all matches to a regular expression in Python?
- How do we find the exact positions of each match in Python regular expression?
- How do we find the exact positions of each match in Python's regular expression?
- How to match a word in python using Regular Expression?
- How to match a whitespace in python using Regular Expression?
- How to remove tabs and newlines using Python regular expression?
- How to match a nonwhitespace character in python using Regular Expression?
- How to match a single character in python using Regular Expression?
- How to find a matching substring using regular expression in C#?
- How to match nonword characters in Python using Regular Expression?

Advertisements