Simplifying text by replacing hyphens with ease
npm install hyphen-sanitizer> Simplifying text by replacing hyphens with ease
!CI


Hyphens are commonly used in strings to separate words or denote compound words. However, in certain scenarios, it's necessary to sanitize hyphens by replacing them with another character or removing them entirely. hyphen-sanitizer provides a simple yet powerful solution for sanitizing hyphens within strings, enhancing data consistency and usability.
- Sanitizes hyphens within strings
- Allows customization of replacement string
- Defaults to space if no replacement string is provided
- Versatile and easy to integrate into existing projects
``sh`
npm install hyphen-sanitizer
`js
import hyphenSanitizer from "hyphen-sanitizer";
// Example 1 - Default replacement
// Replaces hyphens with spaces
const text = "Hello-world";
const sanitizedText = hyphenSanitizer(text);
console.log(sanitizedText); //=> "Hello world"
// Example 2 - Custom replacement
// Replaces hyphens with underscores
const replacement = "_";
const sanitizedText2 = hyphenSanitizer(text, replacement);
console.log(sanitizedText2); //=> "Hello_world"
`
#### input
Type: string
The input string to sanitize. This string may contain hyphens that need to be replaced.
#### replacement
Type: string' '` (space)
Default:
The replacement string to use in place of hyphens. If no replacement string is provided, hyphens will be replaced with spaces.
- acronymer - Generate acronyms from strings
MIT © Palash Mondal