Posted By

jarnaldich on 01/19/11


regex python text camlcase

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


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.