Convert a string to snake_case. Words are lowercased and joined with single
underscores. A word boundary is any of: a run of non-alphanumeric characters
(dropped), a lower-or-digit followed by an uppercase letter (fooBar), or
the tail of an acronym (XMLHttp → xml_http). Word detection and casing
are both Unicode-correct, not ASCII-only.
This is the inverse of camelCase and additionally splits camelHumps,
which is the usual reason to reach for it: snakeCase('fooBar') is
'foo_bar'.
Parameters
value: string
The string to convert.
Returns string
The snake_case string. An empty string is returned unchanged.
Convert a string to snake_case. Words are lowercased and joined with single underscores. A word boundary is any of: a run of non-alphanumeric characters (dropped), a lower-or-digit followed by an uppercase letter (
fooBar), or the tail of an acronym (XMLHttp→xml_http). Word detection and casing are both Unicode-correct, not ASCII-only.This is the inverse of camelCase and additionally splits camelHumps, which is the usual reason to reach for it:
snakeCase('fooBar')is'foo_bar'.