Move split function.
This commit is contained in:
@@ -939,37 +939,6 @@ void handle_command()
|
||||
webserver.send(204, "text/plain", "No Content"); // this page doesn't send back content --> 204
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Splits a string at given character and return specified element
|
||||
*
|
||||
* @param s string to split
|
||||
* @param parser separating character
|
||||
* @param index index of the element to return
|
||||
* @return String
|
||||
*/
|
||||
String split(String s, char parser, int index)
|
||||
{
|
||||
String rs = "";
|
||||
int parser_cnt = 0;
|
||||
int r_from_index = 0, r_to_index = -1;
|
||||
while (index >= parser_cnt)
|
||||
{
|
||||
r_from_index = r_to_index + 1;
|
||||
r_to_index = s.indexOf(parser, r_from_index);
|
||||
if (index == parser_cnt)
|
||||
{
|
||||
if (r_to_index == 0 || r_to_index == -1)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return s.substring(r_from_index, r_to_index);
|
||||
}
|
||||
else
|
||||
parser_cnt++;
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handler for GET requests
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user