lolamontes69

Python / Simple string strippers.

Jun 2nd, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. from string import punctuation
  2. from string import digits
  3. from string import letters
  4. from string import printable
  5. from string import whitespace
  6.  
  7. def punk_stripper(inputtext):
  8.     a = ''.join([t for t in inputtext if t not in punctuation])
  9.     return a
  10.  
  11. def get_numbers(inputtext):
  12.     b = ''.join([t for t in inputtext if t in digits])
  13.     return b
  14.  
  15. def get_letters(inputtext):
  16.     c = ''.join([t for t in inputtext if t in letters])
  17.     return c
  18.  
  19. def get_printable(inputtext):
  20.     d = ''.join([t for t in inputtext if t in printable])
  21.     return d
  22.  
  23. def whitespace_stripper(inputtext):
  24.     e = ''.join([t for t in inputtext if t not in whitespace])
  25.     return e
  26.    
  27. inputtext = str(raw_input('Input some text for the strippers >'))
  28. print "\n\n"
  29. print "punk_stripper:-\t",punk_stripper(inputtext)
  30. print "get_numbers:-\t",get_numbers(inputtext)
  31. print "get_letters:-\t",get_letters(inputtext)
  32. print "get_printable:-\t",get_printable(inputtext)
  33. print "whitespace_stripper:-\t",punk_stripper(inputtext)
Advertisement
Add Comment
Please, Sign In to add comment