/ Published in: Python
Turn a string LikeThis into like_this
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def convert(name): s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()