inline bool startsWith(const std::string &str, const std::string &target) { return str.rfind(target) == 0; } if (startsWith(mystr, "http:")) { ... }Since C++20
if (mystr.starts_with("http:")) { ... }More info https://en.cppreference.com/w/cpp/string/basic_string/starts_with