@corex/string-util
v4.0.43
Published
--- title: '@corex/string-util' custom_edit_url: 'https://github.com/iamvishnusankar/corex/edit/master/packages/string-util/README.md' ---
Downloads
411
Readme
title: '@corex/string-util' custom_edit_url: 'https://github.com/iamvishnusankar/corex/edit/master/packages/string-util/README.md'
toKebabCase
import { toKebabCase } from '@corex/string-util'
// Usage
const result = toKebabCase('Hello World')
// Result
console.log(result)
// "Hello World" => "hello-world"
// "hello world" => "hello-world"
// " Hello World " => "hello-world"
toShortName
import { toShortName } from '@corex/string-util'
// Usage
const result = toShortName('Hello')
// Result
console.log(result)
// "Hello" => "HE"
// "Hello World" => "HW"
// "hello-world" => "HE"
// " hello World " => "HW"
singleWhitespace
import { singleWhitespace } from '@corex/string-util'
// Usage
const result = singleWhitespace('Hello')
// Result
console.log(result)
// "Hello World" => "Hello World"
// " Hello World " => "Hello World"
hasWhiteSpace
import { hasWhiteSpace } from '@corex/string-util'
// Usage
const result = hasWhiteSpace('Hello')
// Result
console.log(result)
// "Hello World" => true
// "HelloWorld" => false
kebabCaseToText
import { kebabCaseToText } from '@corex/string-util'
// Usage
const result = kebabCaseToText('hello-world')
// Result
console.log(result)
// "hello-world" => "hello world"
// "-hello-world-text-" => "hello world text"
replaceSpecialCharacters
import { replaceSpecialCharacters } from '@corex/string-util'
// Usage
const result = replaceSpecialCharacters('hello-world')
// Or replace with
const result = replaceSpecialCharacters('hello-world', *)
// Result
console.log(result)
// "@hello_WORLD#$" => "hello WORLD "
// "-hello-world-text-" => "hello*WORLD**"
toTitleCase
import { toTitleCase } from '@corex/string-util'
// Usage
const result = toTitleCase('hello-world')
// Result
console.log(result)
// "hello WORLD" => "Hello World"
// "hello-world-" => "Hello World"
// "-hello-world-text-" => "Hello World Text"