Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- userString = input('Please enter a string to strip: ')
- charStrip = input('Please enter any characters you\'d like to omit: ')
- def stringStrip(userString, charStrip):
- if charStrip == '':
- noWhite = re.compile(r'[^\s][\w]+[^\s]')
- mo1 = noWhite.search(userString)
- print(mo1.group())
- else:
- noChar = re.compile(r'[' + charStrip + ']')
- mo2 = noChar.sub('', userString)
- print(mo2)
- stringStrip(userString, charStrip)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement