Posted By

jarnaldich on 01/19/11


Tagged

regex python text camlcase


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

magna


CamlCase conversion


 / Published in: Python
 

Turn a string LikeThis into like_this

  1. def convert(name):
  2. s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
  3. return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()

Report this snippet  

You need to login to post a comment.