fork download
  1. import re
  2.  
  3. def camelCase(tag_str):
  4. words = re.findall(r'\w+', tag_str)
  5. nwords = len(words)
  6. if nwords == 1:
  7. return words[0]
  8. elif nwords > 1:
  9. return words[0].lower() + ''.join(map(str.title, words[1:]))
  10. return '' # no word characters
  11.  
  12. tags_str = """ 'tHiS iS a tAg, 'whitespace' !&#^ , secondcomment , no!punc$$,
  13. ifNOSPACESthenPRESERVEcaps' """
  14. print("\n".join(filter(None, map(camelCase, tags_str.split(',')))))
Success #stdin #stdout 0.02s 5808KB
stdin
Standard input is empty
stdout
thisIsATag
whitespace
secondcomment
noPunc
ifNOSPACESthenPRESERVEcaps