I have a string array,"stringArray", with the following contents:
"ADU-30"
"ADU-30 plus a cam"
"ADU-30 plus internal cam"
"ADU-60"
"ADU-60 plus a cam"
"ADU-60 plus internal cam"
"ADU-301"
My goal is to be able to extract the "ADU-" portion including the numeric digits to the right of the hyphen. Currently, I can extract the ones with just two numeric digits to the right of the hyphen as follows:
for (int i = 0; i < stringArray.length(); i++) {
stringArray[i] = stringArray[i].substring(0,6);
}
However, when I change the substring arguments from substring(0,6) to substring(0,7), it crashes on the item with just two digits to the right of the hyphen. How can I store the three digits items? Also, is there a better way to do this then using substring? My desired end result is the following string array:
"ADU-30"
"ADU-60"
"ADU-301"