SHARE
TWEET

Split by Word Casing

aneliabogeva Jun 18th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re
  2.  
  3. words = [str(item) for item in re.split("[,;:.!()\"\'\\\\/\[\] ]+", input())if item != ""]
  4. lower_case = []
  5. upper_case = []
  6. mixed_case = []
  7.  
  8. for word in words:
  9.     if re.compile("^[a-z]+$").match(word):
  10.         lower_case.append(word)
  11.     elif re.compile("^[A-Z]+$").match(word):
  12.         upper_case.append(word)
  13.     else:
  14.         mixed_case.append(word)
  15.  
  16. print("Lower-case: ", end="")
  17. print(", ".join(lower_case))
  18. print("Mixed-case: ", end="")
  19. print(", ".join(mixed_case))
  20. print("Upper-case: ", end="")
  21. print(", ".join(upper_case))
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