#include<string> namespace cutl { /** * @brief Check if a string starts with a given substring. * * @param str the string to be checked. * @param start the substring to be checked. * @param ignoreCase whether to ignore case when comparing, default is false. * @return true if the string starts with the substring, false otherwise. */ boolstarts_with(const std::string &str, const std::string &start, bool ignoreCase = false); /** * @brief Check if a string ends with a given substring. * * @param str the string to be checked. * @param end the substring to be checked. * @param ignoreCase whether to ignore case when comparing, default is false. * @return true if the string ends with the substring, false otherwise. */ boolends_with(const std::string &str, const std::string &end, bool ignoreCase = false); } // namespace cutl
---------------------------------------TestStartswithEndswith--------------------------------------- Hello, world! start with hello : 0 Hello, world! start with hello ignoreCase: 1 GOODBYE, WORLD! end with world! : 0 GOODBYE, WORLD! end with world! ignoreCase: 1