All Courses

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

By Jennifer, 2 years 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 : "How Machine Get Trained in Machine Learning?"

Jun 1st (5:32 PM) 515 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More