Match Wikipedia anchor dot-instead-of-percent encoding string.replace(/((?:.[a-f0-9]{2}){2})/ig, function(match) { return decodeURIComponent(match.replace(/./g, '%')) });