gpt4 book ai didi

c++ - 正则表达式匹配

转载 作者:行者123 更新时间:2023-11-28 03:53:06 24 4
gpt4 key购买 nike

我有一个功能可以检查输入的行是否“OK”。

#include <tr1/regex>

bool lineIsValid(string line) {
const tr1::regex pattern("[^-]{1,30} - [^-]{1,30}");
return tr1::regex_match(line, pattern);
}

lineIsValid("test - test");

函数返回假。为什么?

最佳答案

也许语法没问题,但取决于实现。检查这个post .

this :

After further investigation, I (we) have determined that the TR1 framework supplied by Microsoft with Visual Studio 2008 [and some very early versions of Visual Studio 2010] is buggy, which makes me wonder why the other regex's supplied by Dinkumware are not buggy. Or are they?

关于c++ - 正则表达式匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4716576/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com