1 
2 module autoloader.util;
3 
4 import std.regex;
5 import std..string;
6 
7 /++
8  + Converts a CamelCase string to lower_snake_case.
9  ++/
10 @property
11 string toSnakeCase(string camelCase)
12 {
13     static auto r1 = ctRegex!"(.)([A-Z][a-z]+)";
14     static auto r2 = ctRegex!"(.)([0-9]+)";
15     static auto r3 = ctRegex!"([a-z0-9])([A-Z])";
16 
17     return camelCase
18         .replaceAll(r1, "$1_$2")
19         .replaceAll(r2, "$1_$2")
20         .replaceAll(r3, "$1_$2")
21         .toLower;
22 }