I’m trying to remove accents and special caracteres except dash(-), underline(_) and preserve the extension the string for exemple:
ÁÉÍÓÚáéíóúâêîôûàèìòùÇãç.,~!@#$%&_-12345.png
to:
AEIOUaeiouaeiouaeiouCac_-12345.png
I came to this result but the problem is that it’s ignoring all dots. I need to ignore only last occurence to preserve the extension from filename.
“ÁÉÍÓÚáéíóúâêîôûàèìòùÇãç.,~!@#$%&-12345.png”.normalize(‘NFD’).replace(/[^a-zA-Z0-9-]/g, “”)
I already tried negative look behind like this:
/[^a-zA-Z0-9-]+(?<!.)/g
using this reference but I didn’t have success.
"ÁÉÍÓÚáéíóúâêîôûàèìòùÇãç.,~!@#$%&-12.34.5.png".normalize('NFD').replace(/[^a-zA-Z0-9-]+(?<!.)/g, '')
If i have more than a dot in this case it only removes the first .