Created
November 8, 2022 09:39
-
-
Save jenschr/98ea7c086270718e00c9f119824992a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String getValue(String data, char separator, int index) | |
{ | |
int found = 0; | |
int strIndex[] = { 0, -1 }; | |
int maxIndex = data.length() - 1; | |
for (int i = 0; i <= maxIndex && found <= index; i++) { | |
if (data.charAt(i) == separator || i == maxIndex) { | |
found++; | |
strIndex[0] = strIndex[1] + 1; | |
strIndex[1] = (i == maxIndex) ? i+1 : i; | |
} | |
} | |
return found > index ? data.substring(strIndex[0], strIndex[1]) : ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment