wagtail/wagtail/wagtailcore/utils.py
2014-06-18 11:24:38 +01:00

6 lines
184 B
Python

import re
def camelcase_to_underscore(str):
# http://djangosnippets.org/snippets/585/
return re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', '_\\1', str).lower().strip('_')