Skip to content

snakeCase() function

str 转换为下划线命名。根据空格、标点、数字、大小写边界和缩写词拆分单词。

Signature:

typescript
function snakeCase(str: string): string;

Example

ts
snakeCase("foo bar"); // "foo_bar"
snakeCase("fooBar"); // "foo_bar"
snakeCase("foo-bar"); // "foo_bar"
snakeCase("XMLHttpRequest"); // "xml_http_request"

Open Source Code

Released under the Apache-2.0 License.