Comment convertir la corde en cas Pascal dans JavaScript
const pascalCase = (string) => {
function toPascalCase(string) {
return `${string}`
.replace(new RegExp(/[-_]+/, "g"), " ")
.replace(new RegExp(/[^\w\s]/, "g"), "")
.replace(
new RegExp(/\s+(.)(\w*)/, "g"),
($1, $2, $3) => `${$2.toUpperCase() + $3.toLowerCase()}`
)
.replace(new RegExp(/\w/), (s) => s.toUpperCase());
}
const newText = toPascalCase(string);
return newText
};
mrmalik610