Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

341
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!