# constantcase > Returns a string converted to a constant case.
## Usage ```javascript var constantcase = require( '@stdlib/string/constantcase' ); ``` #### constantcase( str ) Converts a string to constant case. ```javascript var str = constantcase( 'foo bar' ); // returns 'FOO_BAR' str = constantcase( 'foo bar baz' ); // returns 'FOO_BAR_BAZ' str = constantcase( 'foo_bar' ); // returns 'FOO_BAR' ```
## Examples ```javascript var constantcase = require( '@stdlib/string/constantcase' ); var str = 'Hello World!'; var out = constantcase( str ); // returns 'HELLO_WORLD' str = 'I am a tiny little teapot'; out = constantcase( str ); // returns 'I_AM_A_TINY_LITTLE_TEAPOT' str = 'with big problems'; out = constantcase( str ); // returns 'WITH_BIG_PROBLEMS' str = 'To be, or not to be: that is the question.'; out = constantcase( str ); // returns 'TO_BE_OR_NOT_TO_BE_THAT_IS_THE_QUESTION' str = 'isMobile'; out = constantcase( str ); // returns 'IS_MOBILE' ```
* * *
## CLI
### Usage ```text Usage: constantcase [options] [] 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][mdn-regexp], ensure that the `split` option is either properly escaped or enclosed in quotes. ```bash # Not escaped... $ echo -n $'beEp booP\nisMobile' | constantcase --split /\r?\n/ # Escaped... $ echo -n $'beEp booP\nisMobile' | constantcase --split /\\r?\\n/ ``` - The implementation ignores trailing delimiters.
### Examples ```bash $ constantcase 'hello world' HELLO_WORLD ``` To use as a [standard stream][standard-streams], ```bash $ echo -n 'beEp booP' | constantcase BEEP_BOOP ``` To use as a [standard stream][standard-streams], ```bash $ echo -n 'isMobile' | constantcase IS_MOBILE ``` By default, when used as a [standard stream][standard-streams], the implementation assumes newline-delimited data. To specify an alternative delimiter, set the `split` option. ```bash $ echo -n 'beep_boop\tisMobile' | constantcase --split '\t' BEEP_BOOP IS_MOBILE ```