Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

230
Vistas
How to convert a string into four numbers?

I want to have a string that can be converted into four numbers.

For example, it converts a string from E17B1237 into (225, 123, 18, 55), this is converted from hexadecimal into decimal.

E1 => 225,
7B => 123, 
12 => 18, 
37 => 55.

How can I do it? hexadecimal into decimal is just an example, is there any way to do that?

How do I distinguish a string E17B1237, split into (225, 123, 18, 55), then do the conversion. Thanks.

Because I want to have a rectangle in the coordinate, and use x, y, w, h to create a unique ID, then I can also use the unique ID to retrieve x, y, w, h.

How do I create a unique ID(from x,y,w,h) that can be clear to split into four numbers, then do the conversion.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Assuming each hex code within your string has a length of 2, you can chunk your string into an array using .match(/[0-9A-F]{2}/ig) to match consecutive runs of two characters to get the following array:

['E1', '7B', '12', '37']

Once you have this array, you can use .map() on it to return a new array, where each hex code element within your array is converted into its equivalent base 10 (decimal) value. You can do this with the help of parseInt(string, radix), by passing 16 (the base for hexadecimal) as the radix to convert from:

const hexStr = 'E17B1237';
const res = hexStr.match(/[0-9A-F]{2}/ig).map(hexPart => parseInt(hexPart, 16));
console.log(res);

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use toString paramters to convert

function convert(value, from, to) {
  return parseInt(value, from).toString(to);
}

console.log(
  convert('e1', 16, 10),
  convert('123', 10, 16),
);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda