- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2020 09:19 PM
Hi, i have below string as an example and i need to read the text between quotes. could anyone tell me how to do that in javascript?
this is like csv format string but we do not want to split between COMMA and put it in array because some texts between quotes having COMMAS
"text1","text2","","","","text3","text4,text5"
thanks,
ry
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2020 10:55 PM
Hi sry,
Use this code its working tried in Background Script.
var regex =/"(.*?)"/g
var str = '"text1","text2","","","","text3","text4","text5"';
var finalResults = str.match(regex).map(function makeFinalArr(item){
return gs.print(item.replace(/\"/g, ""));
});
//finalResults; // ["text1", "text2","","", "text3", "text4,text5"]
hope this helps!
Please mark the reply as Helpful/Correct, if applicable.
Regards,
Hemant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2020 11:05 PM
Can you mark the answer as ✅ correct if you were able to achieve the requirement? This enables other members to learn from this thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2020 11:20 PM
Hi Hemant, your solution works only if i put the string in between single quotes but i have string just like the below.
var str = "text1","text2","","","","text3","text4,text5";
thanks,
ry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2020 11:31 PM
Hi sry,
var str= "text1","text2","","","","text3","text4,text5";
this is not string as per my knowedge.
A JavaScript string is zero or more characters written inside quotes.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2020 11:34 PM
thank you i got it, it worked like you said when i made the value inside quotes.
thanks a lot,
ry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2020 11:33 PM
still you can do that without hard-cording the single quotes on string.
let me know if you need script ? you did not answer my question how are you getting those values?