Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(args) {
- var inputString = args[0];
- var pattern = /\d+/g;
- var results = [];
- while ((arr = pattern.exec(inputString)) !== null) {
- results.push(arr[0]);
- }
- var collection = [];
- for (var i in results) {
- var tempNum = parseInt(results[i]);
- var tempNumInHex = tempNum.toString(16).toUpperCase();
- if (tempNumInHex.length < 4) {
- var tempArr = [];
- for (var i = 0; i < 4 - tempNumInHex.length; i = i+1) {
- tempArr.push('0');
- }
- tempArr.push(tempNumInHex);
- var final = tempArr.join('');
- collection.push('0x' + final);
- }
- else {
- collection.push('0x' + tempNumInHex);
- }
- }
- var finishedString = collection.join('-');
- console.log(finishedString);
- }
- /*solve(['5tffwj(//*7837xzc2---34rlxXP%$”']);
- solve(['482vMWo(*&^%$213;k!@41341((()&^>><///]42344p;e312']);
- solve(['20']);*/
Advertisement
Add Comment
Please, Sign In to add comment