Transform maps script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 10:59 AM
Hi All,
I have my xlsx data like Number: 13456, 246892, 123,2456
but output like Number: CH013456,CH246892,CH000123,CH002456,some time we have 2or3 zero missing in the column,
I'm using the below code but it will not retrieve the all data, some data missing where column contains 6,4,3numbers.
var numid = source.u_id.toString().trim() ;
var size = 8;
while(numid.length < size){
numid = "0" + numid;
}
numid = "CI0" + numid ;
return numid;
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 04:40 AM
Hi There,
Try parsing it using the regex operations,
you can do it something like,
var inputString = "Number: CH013456,CH246892,CH000123,CH002456,";
// Use regular expressions to extract integers following "CH"
var regex = /CH(\d+)/g;
var matches = [];
var match;
while ((match = regex.exec(inputString)) !== null) {
matches.push(match[1]); // match[1] contains the captured integer
}
gs.print(matches)
here it's printing all the integers in Array/list.
Hope it helps.
Regards,
Varun Sharma