snakecase
Convert a string to snake case.
Usage
var snakecase = require( '@stdlib/string/base/snakecase' );
snakecase( str )
Converts a string to snake case.
var str = snakecase( 'Foo Bar' );
// returns 'foo_bar'
str = snakecase( 'I am a tiny little house' );
// returns 'i_am_a_tiny_little_house'
str = snakecase( 'Hello World!' );
// returns 'hello_world'
Examples
var snakecase = require( '@stdlib/string/base/snakecase' );
var str = 'foo bar baz';
var out = snakecase( str );
// returns 'foo_bar_baz'
str = 'foo_baz';
out = snakecase( str );
// returns 'foo_baz'
str = 'foo_bar_baz!';
out = snakecase( str );
// returns 'foo_bar_baz'
str = 'beep boop!';
out = snakecase( str );
// returns 'beep_boop'
str = 'foo-baz';
out = snakecase( str );
// returns 'foo_baz'
str = 'Welcome! ๐';
out = snakecase( str );
// returns 'welcome_๐'