あなたは正規表現を使用することができます。
C++ 11の正規表現は、STDライブラリ regex c++11に組み込まれています。
何らかの理由でC++ 11を使用できない場合は、ブーストライブラリを使用できます。あなたはもっと自分に合った正規表現を見つけることができる[このサイト](https://mathiasbynens.be/demo/url-regex)から
#include <regex> //require c++11
// ...
// regex pattern
std::string pattern = "https?:\/\/(www\.)?[[email protected]:%._\+~#=]{2,256}\.[a-z]{2,4}\b([[email protected]:%_\+.~#?&//=]*)";
// Construct regex object
std::regex url_regex(pattern);
// An url-string for example
std::string my_url = "http://www.google.com/img.png";
// Check for match
if (std::regex_match(my_url, url_regex) == true) {
std::cout << "This is a well-formed url\n";
} else {
std::cout << "Ill-formed url\n";
}
:
とにかくあなたがURLのパタパタをチェックできますニーズ。 –