dec
Converts decimal entities
Created by: hackvertor
Installed 1 times
Category: Convert
Created on: Thursday, October 3, 2024 at 6:54:03 PM
Updated on: Thursday, October 31, 2024 at 6:39:45 PM
Tag arguments
[]
Code
class dec {
encode(input) {
return input.split('').map(chr => '&#'+chr.codePointAt()+';').join('');
}
decode(input) {
return input.replaceAll(/&#\d+;/gi, c => String.fromCodePoint(parseInt(c.replaceAll(/[&#;]/g,''))));
}
matches(input) {
return /^(?:&#\d+;)+/.exec(input);
}
}