SHARE
TWEET

Untitled

a guest Jul 15th, 2019 11 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #%%
  2. openn = '<'
  3. closed = '>'
  4. #%%
  5. message ='one<test>two<test>three<test>four'
  6.  
  7. #%%
  8. import re as re
  9. close = [n.start() for n in re.finditer(closed, message)]
  10. open = [m.start() for m in re.finditer(openn, message)]
  11. #%%
  12. stri = []
  13. for i in range(len(open)):
  14.     if (i==0):
  15.         stri = message[0:open[i]]
  16.         print(stri)
  17.     elif(i == (len(open))-1):
  18.         stri+= message[close[i]:]
  19.         print('last')
  20.     else:
  21.         stri+= message[close[i]:open[i+1]]
  22.     print(stri)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top