JSFiddle - React, Tailwind, and code Playground
JavaScript
const specialChars = /[^a-z\d_]/i;
const value = '¾'
sanitizedValue = value
.split(specialChars)
.reduce((reduced, val, idx) => {
let newVal = val;
if (idx > 0) {
console.log(idx, val)
newVal = `${val[0].toUpperCase()}${val.slice(1)}`;
}
return `${reduced}${newVal}`;
})
console.log(sanitizedValue)