Advertisement
here2share

# split_replace.py

Sep 8th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. # split_replace.py
  2.  
  3. sss = "python 123abc xyz ###abc### 123 ###abc###"
  4. item = 'abc'
  5.  
  6. def split_replace(sss):
  7.     s=''
  8.     while item in sss: tmp,sss = sss.lstrip().split(item,1); s += item+' '+tmp+' '
  9.     return s + item+' '+sss
  10. print split_replace(sss)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement