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

83
Vistas
how to remove words start with # from string

i have title like this "hello my #name is #ahmed kotsh" and i want to remove #name #ahmed , any word start with # and the extra spaces after delete the hashtag

expect result "hello my is kotsh" my try works but i know there is better code and more cleaner

const text = "hello my #name is #ahmed kotsh";
  const arr = text.split(" ");
  let newText = "";
  arr.map((i) => {
    if (i[0] != "#") newText = newText + i + " ";
  });
  console.log(newText);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use a regular expression that matches # followed by non-space characters, and replace with nothing.

const text = "hello my #name is #ahmed kotsh";
console.log(
  text.replace(/#\S+ ?/g, '')
);

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