JavaScript Convert comma-separated string to nested array, RegExp? convert comma separated string to list,convert comma separated string

Got this type of string:

var myString = '23, 13, (#752, #141), $, ASD, (#113, #146)';

I need to split it to an array with comma as separator but also converts (..) to an array.

This is the result I want: [23, 13, ['#752', '#141'], '$', 'ASD', ['#113', '#146']];

I got huge data-sets so its very important to make it as fast as possible. What's the fastest way? Do some trick RegExp function or do it manually with finding indexes etc.?

Here's a jsbin: https://jsbin.com/cilakewecu/edit?js,console

Answer:1

I was struggling with understanding how error handling works inside a Node.js stream pipeline and I ended up experimenting using a simple playground which made things crystal clear for me. I am ...

I was struggling with understanding how error handling works inside a Node.js stream pipeline and I ended up experimenting using a simple playground which made things crystal clear for me. I am ...

I want to crawl web after executing javascript "Click" event The web looks like below, function initPage() { initCorpInfo(); var Tree = Ext.tree; var treeRoot = new Tree.TreeNode({ text: "...

I want to crawl web after executing javascript "Click" event The web looks like below, function initPage() { initCorpInfo(); var Tree = Ext.tree; var treeRoot = new Tree.TreeNode({ text: "...

I have a HTML like this: <fieldset> <legend>Incassi previsionali</legend> <div class="sez-form"> <table id="inc_prev"> <tr> <...

I have a HTML like this: <fieldset> <legend>Incassi previsionali</legend> <div class="sez-form"> <table id="inc_prev"> <tr> <...

  1. append container jquery
  2. container.append javascript
  3. container.append is not a function
  4. c++ append container
  5. append div container
  6. cics append container
  7. docker append container
  8. append svg container
  9. image_install_append container
  10. append div to container jquery

I'm looking to be able to link the x-labels in a Chart.js bar chart. I've searched pretty thoroughly, and ended up trying to come up with my own solution: because the labels correspond to the bars ...

I'm looking to be able to link the x-labels in a Chart.js bar chart. I've searched pretty thoroughly, and ended up trying to come up with my own solution: because the labels correspond to the bars ...

  1. link chart label to cell
  2. excel link chart label to cell