I have a need to split a string in javascript to individual components. Let me go through the example of the requirement I'm having.
This is the string I'm having:
"[InsertDelta, position: 63, lines: [return {]]"
I need to split the above string into three components as below:
InsertDela
position: 63
lines: [return {]
Is there any way to separate the strings like this in javascript?
You can use split to split the string at "," and then use for each to iterate through the items.
let y = "[InsertDelta, position: 63, lines: [return {]]";
let x = y.split(",");
x.forEach(item => console.log(item.replace(/\[?\]?/g, "")));