Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #import sys
  2. import re
  3.  
  4. String = "1rrtrn2rrn3rrrrnrnr4nr"
  5. splitString = String.split('n')
  6. replacedStrings = []
  7. i=0
  8.  
  9. for oneString in splitString:
  10. #oneString = oneString.replace(r'^(.?)*(\[^n])+(.?)*$', "")
  11. oneString = re.sub(r'^(.?)*(\[^n])+(.?)*$', "", oneString)
  12. print(oneString)
  13. replacedStrings.insert(i, oneString)
  14.  
  15. i += 1
  16.  
  17. print(replacedStrings)
  18.  
  19. 1
  20. 2
  21. 3
  22.  
  23. 4
  24.  
  25. ['1rrtr', '2rr', '3rrrr', 'r', 'r4', 'r']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement