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

67
Views
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 answers
Answer question

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 Report

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 Report
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!