Advertisement
here2share

# str_find_all_indexes.py

Mar 27th, 2021
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. # str_find_all_indexes.py
  2.  
  3. import re
  4. aString = 'this is a string where the substring "is" is repeated several times'
  5. print [(a.start(), a.end()) for a in list(re.finditer('is', aString))]
  6. [(2, 4), (5, 7), (38, 40), (42, 44)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement