By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,964 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,964 IT Pros & Developers. It's quick & easy.

little endian

P: n/a
CTG

var x = "B113769A"

How do you convert B113769A to "9A7613B1" to get the proper
conversion ?
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
RobG wrote on 22 mei 2008 in comp.lang.javascript:
On May 22, 11:09 am, CTG <BadMul...@gmail.comwrote:
>var x = "B113769A"
// Return if has invalid characters
if (/[^a-f0-9]/.test(x.toLowerCase())) return;
if ( /[^a-f0-9]/i.test(x) ) 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('');
Nice! Will remember that one.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 27 '08 #2

P: n/a
On May 22, 5:09*pm, "Evertjan." <exjxw.hannivo...@interxnl.netwrote:
RobG wrote on 22 mei 2008 in comp.lang.javascript:
On May 22, 11:09 am, CTG <BadMul...@gmail.comwrote:
var x = "B113769A"
* // Return if has invalid characters
* if (/[^a-f0-9]/.test(x.toLowerCase())) return;

if ( /[^a-f0-9]/i.test(x) ) return;
Ah yes...
>
* // 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('');

Nice! Will remember that one.
Credit where credit's due - the inspiration came from the second
banana example here:

<URL: http://www.merlyn.demon.co.uk/js-valid.htm#JS >
--
Rob
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.