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

69
Vistas
How to split multiple in javascript string

Hi I am new at learning JavaScript.

Here is my string "Hello (mon) super (Henry)" there is another string "Hello (wed) class (Mario)"

I wish to not have (mon) and (wed), and things beyond it.

I tried

let dummyString = 'Hello (wed) class';
dummyString = dummyString.split('(mon)')[0];
dummyString = dummyString.split('(wed)')[0];
console.log(dummyString);

this works perfect but when I use below code

let dummyString = 'Hello (wed) class';
dummyString = dummyString.split('(mon),(wed)')[0];
console.log(dummyString);

it doesn't work

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

0

A regex replacement is probably the most straightforward approach here:

var inputs = ["Hello (mon) super", "Hello (wed) class"];
inputs = inputs.map(x => x.replace(/\s*\(.*?\)\s*/, " ").trim());
console.log(inputs);

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can simply split with ( and ) with irrespective of the string it contains in between.

let dummyString = 'Hello (wed) class';

console.log(dummyString.split(' (')[0], dummyString.split(') ')[1])

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