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

197
Views
how do i split comma separated string in JS excluding json data

I have a string as

ABC, CDE, [{"ab":"1","cv":"23"},{"ab":"1","cv":"2%3A1639251967619%2C%22v%22%3A1%7D"}]

I want to split to get array of length 3 two strings and 3rd string with json array as string

ABC
CDE
[{"ab":"1","cv":"23"},{"ab":"1","cv":"2%3A1639251967619%2C%22v%22%3A1%7D"}]

using JS

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do it by using split method like this:

const str = 'ABC,CDE,[{"ab":"1","cv":"23"},{"ab":"1","cv":"2%3A1639251967619%2C%22v%22%3A1%7D"}]';
let value = str.replace(/\w,/g, (match) => match[0] + '#').split('#');
// if you want to convert 3rd item to a valid JS object you can parse it, else you can miss next line:
value[2] = JSON.parse(value[2]);
console.log(value)

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!