To find the words ending with an accentuated char and log them.
I thought this could do it.
const text = 'aztec, résumé, façade, and azure';
const words = text.match(/\b\w*[éèêëáàâäíìîïóòôöúùûüç]\b/g);
console.log(words);
`
But all I get is > ré,faç
\b
will not work since it will also treat accented characters as a \b
.
Instead you could use the u
(unicode) flag, and before your list of accented characters use \p{L}
and in the end check if followed by a non word character or end of line: Regex.101 example
const text = 'aztec, résumé, façade, and azure, mardí';
const words = text.match(/\p{L}*[éèêëáàâäíìîïóòôöúùûüç](?=\W|$)/ug);
console.log(words);