skip to Main Content

I am using split function in javascript that will split arraylist coming from java on the basis of comma. But I am facing an issue where words having comma are splitted into two separated words. How do I overcome this problem.

Example-

["Technology Science", "Maths", "Fundamental,Theory of computation"]

Output using split (,) in js:-

"Technology Science", "Maths", "Fundamental","Theory of computation"

Expected:-

"Technology Science", "Maths", "Fundamental,Theory of computation"

2

Answers


  1. You can split on ", ", assuring that the initial " is not escaped.

    (?<!\)", "
    
    Login or Signup to reply.
  2. That format is coincidentally compatible with JSON. Because of that, you can use:

    let titles=JSON.parse(arraylistOutput);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search