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.