CamelCase2snake_case()
Retina, 61 37 bytes

r1&gt;`[A-Z]?[a-z]+|[A-Z]+|\d+
_$&amp;
T`L`l


Try it online! (Slightly modified to run a full test suite.)

Explanation

Instead of finding word boundaries to insert underscores, we simply match each word and prepend a _. Matching words from the left is a bit annoying because of the UUl rule, but using .NET's right-to-left matching we can easily match words greedily. To avoid a leading _, we make use of Retina's limits.

r1&gt;`[A-Z]?[a-z]+|[A-Z]+|\d+
_$&amp;


The r activates right-to-left mode, the 1&gt; tells Retina to process everything except the first match (counting from left to right). Then there's four types of "words": Ulll, lll, UUU, ddd. These are easily matched with the given pattern. The substitution just writes a _ followed by the word itself.

T`L`l


This simply turns upper case into lower case to complete the transformation.