I have the following string
"[01][23.81][New]"
I am trying to break up the string by retrieving the values between the brackets and placing them into an array so that it looks something like the following
array({
"id" : 01,
"price" : 23.81,
"condition" : "New"
});
Here is what I have so far…
var arr = new Array();
$("input:checkbox.addItm:checked").each(function(){
//str.split('[');
arr.push({
"id": $(this).val()
});
});
I want to know what is the best way to split the string?
You can use a regular expression instead: