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

162
Vistas
How to implement a function that matches a specific paragraph in JavaScript?

full url : abc.com/product/123

find url : abc.com/product

I want to return true if the full url contains find url

The condition must match the sentences of find url and the words in the full url perfectly.

fullurl.indexOf('abc') // this find true It is a condition that only certain words should not be split.

I want the result value

fullurl = 'abc.com/product/123'; 
findurl = 'abc.com/product';

fullurl.indexOf('abc'); // this find false 
fullurl.indexOf('pro'); // this find false 
fullurl.indexOf('abc.com'); // this find false 
fullurl.indexOf('abc.com/product'); // this true This result is the return value I want

I can't get the result I want with the indexOf function alone. What should I do?

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

0

This will return true if fullurl contains findurl.

I used regex, if you want to change the findurl you need to edit the regex code.

function matchUrl(fullurl) {
  reg = /\babc.com\/product\b/;
  if (fullurl.match(reg)) {
    return true;
  }
  return false;
}

Check this out to further understand the regex I used.

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