1234567891011121314151617181920212223
std::string cmdstr = "start/next/end"; std::string cmd = ""; cmd = GetFirstParam(cmdstr, '/'); std::string GetFirstParam(std::string ¶m, const char seperator) { std::string cmd = ""; uint8_t pos = param->find(seperator); if (pos == 0) { param->erase(0,1); pos = param->find(seperator); } if (pos == -1) { pos = param->length();} if (pos > 0) { cmd = param->substr(0, pos); param->erase(0, pos + 1); } return cmd; }