Advertisement
Guest User

Strip()

a guest
Jul 28th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import re
  2.  
  3. str = "!!!!!!!!!Haha!!!"
  4.  
  5. #['  Haha  ']
  6.  
  7.  
  8.  
  9.  
  10.  
  11. def sudo_strip(string, arg2 = ' '):
  12.     stripRegex = re.compile(r'{0}+(.*){1}+$'.format(arg2, arg2))
  13.     mo = stripRegex.findall(string)
  14.     print(mo[0])
  15.     s2Regex = re.compile(r'(.*)' + re.escape(arg2) + r'+')
  16.     om = s2Regex.findall(mo[0])
  17.     print(om[0])
  18.     s3Regex = re.compile(r'(.*)' + re.escape(arg2) + r'+')
  19.     ro = s3Regex.findall(om[0])
  20.     print(ro[0])
  21.  
  22.  
  23. sudo_strip(str, '!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement