create a helper function to get kebab cases of differenly cased strings
This commit is contained in:
parent
87decd0d83
commit
1671946668
1 changed files with 7 additions and 0 deletions
|
|
@ -25,3 +25,10 @@ export function replaceEscapedCharacters(str: string): string {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function kebabOfStr(str: string): string {
|
||||
return str
|
||||
.replace(/([a-z])([A-Z])/g, "$1-$2") // handle camelCase and PascalCase
|
||||
.replace(/[\s_]+/g, "-") // replace spaces and underscores with hyphens
|
||||
.toLowerCase();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue