Source code for co3.util.regex import re camel2snake_regex = re.compile(r'(?<!^)(?=[A-Z])') [docs] def camel_to_snake(text): return camel2snake_regex.sub('_', text).lower()