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

335
Vistas
regex exec is first time say==true then its givin me null problem is not null

function findSimilarity(str, word) {
  const reg = /(^.)(.*)(.$)/g;
  word = reg.exec(word);

  const findSpaceRegex = /([^ ]+)/g;
  str = str.match(findSpaceRegex);
  return str.map((e) => {
    if (
      reg.exec(word)[1] == reg.exec(e)[1] &&
      reg.exec(word)[2].length == reg.exec(e)[2].length &&
      reg.exec(word)[0] != reg.exec(e)[0] &&
      reg.exec(word)[3] == reg.exec(e)[3]
    )
      console.log(true);
  });
}

console.log(findSimilarity("bag dog dig dot doog dogs", "dog"));

this is my code and when i try to solve this https://www.codewars.com/kata/573975d3ac3eec695b0013e0/train/javascript kata i use exec but problem is exec working just once. than when i want to exec all of them its says null but the problem is not null. when i say a.match(Regex) its work well but it does not need my needs. so what is my problem or what is map problemler i want to thanks to right know for answering question.

about 4 years ago · Santiago Gelvez
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