- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 09:50 PM - edited 09-05-2024 09:51 PM
Hi Community,
There is one field of type 'glide-list' & I want to split them with comma but the issue is value itself contains comma.
Please see the screenshot below:-
var grp=gr.groupings.getDisplayValue()).split(",");
It display value as:
['Entity Update - Norway', 'Entity Update - Sweden', 'Latvia & Lithuania'] which means it's splitting array as
grp[0]=Entity Update - Norway
grp[1]=Entity Update - Sweden
grp[2]=Latvia & Lithuania
I want it as below:-
grp[0]=Entity Update - Norway
grp[1]=Entity Update - Sweden, Latvia & Lithuania
i.e. It should always start with 'Entity Update' and end before ',Entity Update'.
I tried multiple regex methods & checked on community but didn't find any solution.
Could someone please help me on this?
Thanks in advance!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 10:24 PM
Try it!
var grp = gr.groupings.getDisplayValue(); // Get the value of the glide-list
var regex = /, (?=Entity Update)/; // Regular expression to split at ", " only when followed by "Entity Update"
var splitGrp = grp.split(regex); // Use the regex to split the string
// Output the split values
for (var i = 0; i < splitGrp.length; i++) {
gs.info("grp[" + i + "]=" + splitGrp[i]);
}
Output
grp[0] = Entity Update - Norway
grp[1] = Entity Update - Sweden, Latvia & Lithuania
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 10:24 PM
Try it!
var grp = gr.groupings.getDisplayValue(); // Get the value of the glide-list
var regex = /, (?=Entity Update)/; // Regular expression to split at ", " only when followed by "Entity Update"
var splitGrp = grp.split(regex); // Use the regex to split the string
// Output the split values
for (var i = 0; i < splitGrp.length; i++) {
gs.info("grp[" + i + "]=" + splitGrp[i]);
}
Output
grp[0] = Entity Update - Norway
grp[1] = Entity Update - Sweden, Latvia & Lithuania
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 11:46 PM
Hello @HIROSHI SATOH ,
Thank you so much for your instant response 🙂 It's working now.
You are the saviour.