fork download
  1. import re
  2.  
  3. def extract_all_after_pattern(search_after_rx, reg, text):
  4. search_after = re.search(search_after_rx, text)
  5. if search_after:
  6. print(f"Found at {search_after.start()}, searching from {len(search_after.group())}, i.e. in '{text[search_after.end()+1:]}'")
  7. return reg.findall(text, search_after.end()+1)
  8. else:
  9. return []
  10.  
  11. text = "we have a Newliner Chatacter in 10000 the Middle of the sentence"
  12. search_after_rx = r'\ba\b' # Or, r'a\s', r'\sa\s', r'(?<!\S)a(?!\S)', etc.
  13. reg = re.compile(r'\w+')
  14. print(extract_all_after_pattern(search_after_rx, reg, text))
Success #stdin #stdout 0.02s 9432KB
stdin
Standard input is empty
stdout
Found at 8, searching from 1, i.e. in 'Newliner Chatacter in 10000 the Middle of the sentence'
['Newliner', 'Chatacter', 'in', '10000', 'the', 'Middle', 'of', 'the', 'sentence']