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

By Jennifer, 6 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

More webinars

Related Discussions

Running random forest algorithm with one variable

View More
We're Online!

Chat now for any query