Advertisement
here2share

# re_split.py

Sep 30th, 2024
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. # re_split.py
  2.  
  3. import re
  4.  
  5. def findall_lossless(text):
  6.     result = re.findall(r'\b\w+\b|\s+|[^\w\s]+', text)
  7.     return result
  8.  
  9. method = "Hello, world! This is a test-case."
  10. result = findall_lossless(method)
  11.  
  12. for z in result:
  13.     print([z])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement