So I have a database string
which is <@$244230034359844866> <@$244230033359844566>
. How would I make it so that when I do console.log it only shows up with 244230034359844866, 244230033359844566
Thanks
2 Answers
As mentioned by @Sagar you can create string list and then simply use replaceAll('\D','') to get only numbers from string.
var myStringArray = ["<@$244230034359844866>","<@$244230034359844868>"];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
system.debug(myStringArray[i].replaceAll('\\D',''));
}
@NotAndy, you can put the string into a list and then iterate over it to fetch the number using subString function of string. I am assuming that the string format will always be same as you mentioned above. Please find the code below for your reference-
var myStringArray = ["<@$244230034359844866>","<@$244230034359844868>"];
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
console.log(myStringArray[i].substring(3, 21));
}