I'm currently working on masking strings using JavaScript regex. However, I've encountered an issue with non-ascii characters. How would you suggest resolving this problem?
Below is the code I've been using:
var name = "Üsüaüü Bxbdüxüqzx Aqwexü"
var regex = /(?<![\p{L}\p{Mn}\p{Nd}_])(\p{L})(\p{L}*)\b/ug
console.log(name.replace(regex, (_, first, middle, last) => `${first}${'*'.repeat(middle.length)}`))
Expected output:
Ü***** B********* A*****
Appreciate any input on solving this issue.