C
CTG
var x = "B113769A"
How do you convert B113769A to "9A7613B1" to get the proper
conversion ?
How do you convert B113769A to "9A7613B1" to get the proper
conversion ?
var x = "B113769A"
How do you convert B113769A to "9A7613B1" to get the proper
conversion ?
// Return if has invalid characters
if (/[^a-f0-9]/.test(x.toLowerCase())) return;
// Might need left padding
x = (x.length % 2)? '0'+x : x;
// Split into an array of pairs, reverse and join again
return x.match(/../g).reverse().join('');
RobG wrote on 22 mei 2008 in comp.lang.javascript:
// Return if has invalid charactersvar x = "B113769A"
if (/[^a-f0-9]/.test(x.toLowerCase())) return;
if ( /[^a-f0-9]/i.test(x) ) return;
Nice! Will remember that one.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.