C ++で特殊文字のブーストパターンを作成する方法を知っている人はいますか?
つまりそれだけでなく("[A-Za-z0-9 \\s]*")
などなど、_ + - \ ) \\ ( . | ]
たとえば次のような文字列:
"hello world \\has (special.characters) + defined_with[boost]"
有効です
しかし
"!hello world \\has (special.characters) + defined_with[boost]"
有効じゃない
より具体的には、次のようなものです。
string input;
getline(cin,input);
boost::regex pattern1 ("[a-zA-Z0-9 \\s \\_ \\+ \\- \\\ \\) \\\\ \\( \\. \\| ]*");
if (!regex_match (input, pattern1))
{
cout << "invalid input" << endl;
}
else
cout << input << " - is valid" << endl;
あなたが提供できるどんな助けにも感謝します