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

246
Vistas
How to get the first string's from the right hand side

So I have this code that would get the first string's from the right hand side and stop whenever there is an integer but for some reason its not working with me.

Example input of fUnit is "CS_25x2u"

expected output of it after using unit is "u".

Real output is "undefined".

function buildUnit(fUnit){// wahts ginna be passed here is the gibirish unit and the output of this function is the clear unit
    fUnit = fUnit.toString;
    const regex = /[a-zA-Z]*$/;
    const unit = (x) => x.match(regex)[0];
    fUnit = unit(fUnit);

If you need more info please let me know

Thank you

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

0

const regex = /[a-zA-Z]*$/;
console.log(regex.exec(sample));

Assuming fUnit variable contains your string

const unit = (x) => x.match(regex)[0];
console.log(unit(fUnit));
about 4 years ago · Juan Pablo Isaza Denunciar

0

Just in case.

function buildUnit(fUnit) {
  return fUnit.toString().match(/[A-z]*$/)[0];
}

console.log(buildUnit('CS_25x2u'));    // 'u'
console.log(buildUnit(''));            // ''
console.log(buildUnit(123));           // ''
console.log(buildUnit('aaa123'));      // ''
console.log(buildUnit('aaa 123 bbb')); // 'bbb'

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