stl 正規表現クラスを使用すると、次のスニペットのようなことができます。残念ながらutf8ではありません。に変更str2
するstd::wstring str2 = L"hello World"
と、多くの変換警告が表示されます。std::regex はwhar入力を許可していないため (私が見る限り)、作成はまったく機能しませんstr1
。std::wchar
#include <regex>
#include <iostream>
#include <string>
int main()
{
//The input strings
std::string str1 = "Hello";
std::string str2 = "hello World";
//Define the regular expression using case-insensitivity
std::regex regx(str1, std::regex_constants::icase);
//Only search at the beginning
std::regex_constants::match_flag_type fl = std::regex_constants::match_continuous;
//display some output
std::cout << std::boolalpha << std::regex_search(str2.begin(), str2.end(), regx, fl) << std::endl;
return 0;
}