Skip to content

Instantly share code, notes, and snippets.

@oliverlundquist
Created May 11, 2016 02:19
Show Gist options
  • Save oliverlundquist/f98050e5c503d8a68dbfc6d008946796 to your computer and use it in GitHub Desktop.
Save oliverlundquist/f98050e5c503d8a68dbfc6d008946796 to your computer and use it in GitHub Desktop.
Double Byte to Single Byte (JS)
var input = 'Taro Suzuki 234234234456456';
var output = input
.replace(/[]/g, 'A')
.replace(/[]/g, 'B')
.replace(/[]/g, 'C')
.replace(/[]/g, 'D')
.replace(/[]/g, 'E')
.replace(/[]/g, 'F')
.replace(/[]/g, 'G')
.replace(/[]/g, 'H')
.replace(/[]/g, 'I')
.replace(/[]/g, 'J')
.replace(/[]/g, 'K')
.replace(/[]/g, 'L')
.replace(/[]/g, 'M')
.replace(/[]/g, 'N')
.replace(/[]/g, 'O')
.replace(/[]/g, 'P')
.replace(/[]/g, 'Q')
.replace(/[]/g, 'R')
.replace(/[]/g, 'S')
.replace(/[]/g, 'T')
.replace(/[]/g, 'U')
.replace(/[]/g, 'V')
.replace(/[]/g, 'W')
.replace(/[]/g, 'X')
.replace(/[]/g, 'Y')
.replace(/[]/g, 'Z')
.replace(/[]/g, '1')
.replace(/[]/g, '2')
.replace(/[]/g, '3')
.replace(/[]/g, '4')
.replace(/[]/g, '5')
.replace(/[]/g, '6')
.replace(/[]/g, '7')
.replace(/[]/g, '8')
.replace(/[]/g, '9')
.replace(/[]/g, '0')
.replace(/[ ]/g, ' ')
.toUpperCase();
// Input: Taro Suzuki 234234234456456
// Output: TARO SUZUKI 234234234456456
console.log('Input: ' + input);
console.log('Output: ' + output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment