dotcase

Convert a string to dot case.

Usage

var dotcase = require( '@stdlib/string/dotcase' );

dotcase( str )

Converts a string to dot case.

var out = dotcase( 'foo bar' );
// returns 'foo.bar'

out = dotcase( 'IS_MOBILE' );
// returns 'is.mobile'

out = dotcase( 'Hello World!' );
// returns 'hello.world'

out = dotcase( '--foo-bar--' );
// returns 'foo.bar'

Examples

var dotcase = require( '@stdlib/string/dotcase' );

var str = 'Hello World!';
var out = dotcase( str );
// returns 'hello.world'

str = 'HELLO WORLD!';
out = dotcase( str );
// returns 'hello.world'

str = 'To be, or not to be: that is the question.';
out = dotcase( str );
// returns 'to.be.or.not.to.be.that.is.the.question'

CLI

Usage

Usage: dotcase [options] [<string>]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.
         --split sep           Delimiter for stdin data. Default: '/\\r?\\n/'.

Notes

  • If the split separator is a regular expression, ensure that the split option is either properly escaped or enclosed in quotes.

    # Not escaped...
    $ echo -n $'beep\nfoo_bar' | dotcase --split /\r?\n/
    
    # Escaped...
    $ echo -n $'beep\nfoo_bar' | dotcase --split /\\r?\\n/
    
  • The implementation ignores trailing delimiters.

Examples

$ dotcase 'hello world!'
hello.world

To use as a standard stream,

$ echo -n 'beEp booP' | dotcase
beep.boop

By default, when used as a standard stream, the implementation assumes newline-delimited data. To specify an alternative delimiter, set the split option.

$ echo -n 'beep\tfoo_bar' | dotcase --split '\t'
beep
foo.bar
Did you find this page helpful?