JavaScript Snippet - Convert CamelCase to snake_case

Posted at


"CheckMarkLegacy"
.replace(/([A-Z])/g, "_$1")
.replace(/^_*/, "").toLowerCase()
;

/* outputs: check_mark_legacy */