[英]Is that a feature or a bug of clang c++11 std::regex_match?
[英]C++11 regex_match does not match what it must
std::string pattern = "[disk0-9]";
std::regex regex(pattern, std::regex::ECMAScript);
std::string subject = "Disk1";
bool result = std::regex_match(subject, regex, std::regex_constants::match_any);
std::cout << result << std::endl;
拜托,為什么regex_match
返回false?
修改代碼如下:
std::string pattern = "disk[0-9]";
std::regex regex(pattern, std::regex::ECMAScript | std::regex::icase); //Ignore Case
根據評論,正確答案應為(包括字母D的可變大小寫):
pattern = "[Dd]isk[0-9]"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.