How to find all the adverbs and their positions using the re module?

By Jennifer, 7 months ago
  • Bookmark
0

Find the adverbs from string using regular expression (re) module

Regular expression
Python
1 Answer
0

Find all the adverbs and their positions using the re module


import re
text = "She made me laugh wildly and uproariously."
for v in re.finditer(r"\w+ly",text):
  print('%d-%d: %s' %(v.start(), v.end(),v.group(0)))

Output

18-24: wildly
29-41: uproariously


Your Answer

Webinars

Live Masterclass on "Python for Artificial Intelligence"

Dec 4th (7:00 PM) 213 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More