nuttyernurse
Technical User
I need to split the string below to only get the numbers after the "=" sign and before the word "unit" There is a possibility that this could be a 2 digit number. I will need to have each number available to assign to a text box.
Sensitive 0601-2059 bg</=70 hypoglycemia*71-150 no insulin*151-200=1 unit*201-250=2 unit*251-300=3 unit*301-350=4 unit*351-400=5 unit* 2100-0600 bg</=70 hypoglycemia*71-200 no insulin*201-250=0 unit*251-300=1 unit*301-399=2 unit*
I was able to get help with getting the numbers to display an alert, but I need the numbers to be separate values I can work with.
Here is the script with the alert:
function splitString(){
var str="Sensitive 0601-2059 bg</=70 hypoglycemia*71-150 no insulin*151-200=1 unit*201-250=2 unit*251-300=3 unit*301-350=4 unit*351-400=5 unit* 2100-0600 bg</=70 hypoglycemia*71-200 no insulin*201-250=0 unit*251-300=1 unit*301-399=2 unit*";
var wordArray = str.split("=");
for(i = 0;i<wordArray.length;i++){
//Split now on unit
if(wordArray.indexOf("unit")>0){
//Split on unit
var wordArray2 = wordArray.split("unit");
alert("Number is "+wordArray2[0]);
}
}
}
Thank you for any help you can offer!
Sensitive 0601-2059 bg</=70 hypoglycemia*71-150 no insulin*151-200=1 unit*201-250=2 unit*251-300=3 unit*301-350=4 unit*351-400=5 unit* 2100-0600 bg</=70 hypoglycemia*71-200 no insulin*201-250=0 unit*251-300=1 unit*301-399=2 unit*
I was able to get help with getting the numbers to display an alert, but I need the numbers to be separate values I can work with.
Here is the script with the alert:
function splitString(){
var str="Sensitive 0601-2059 bg</=70 hypoglycemia*71-150 no insulin*151-200=1 unit*201-250=2 unit*251-300=3 unit*301-350=4 unit*351-400=5 unit* 2100-0600 bg</=70 hypoglycemia*71-200 no insulin*201-250=0 unit*251-300=1 unit*301-399=2 unit*";
var wordArray = str.split("=");
for(i = 0;i<wordArray.length;i++){
//Split now on unit
if(wordArray.indexOf("unit")>0){
//Split on unit
var wordArray2 = wordArray.split("unit");
alert("Number is "+wordArray2[0]);
}
}
}
Thank you for any help you can offer!