JSFiddle - React, Tailwind, and code Playground
Convert Shift_JIS numbers into plain numbers via index and array
by Yurii Predborskyi
HTML
<div>
Result: <span id='result'></span>
</div>
CSS
body {
color: white;
}
JavaScript
let s = 'ご利用回数 5回 (980円/回)';
let spl = s.split('');
let conversionTable = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
let res = spl.map(function(el) {
if (conversionTable.indexOf(el) !== -1) {
return conversionTable.indexOf(el);
}
return el;
}).join('');
console.log(res);
let result = /((\d+)円/回)/.exec(res)
console.log(result)
if (result) document.getElementById('result').innerHTML= 'success! number: ' + result[1];