Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ QRegex未标识“\n”_C++_Qregexp - Fatal编程技术网

C++ QRegex未标识“\n”

C++ QRegex未标识“\n”,c++,qregexp,C++,Qregexp,我的程序从comandline获取配置。comandline是这样的: mapPath=此处上方的某些路径\n路径路径=此处上方的其他路径\n 请注意中间和结尾的\n。 我的理由是: QString config("mapPath=Some_Path_Over_Here\npluginsPath=Other_Path_Over_Here\n") QRegExp reg("mapPath=(.*)\\npluginsDir=(.*)\\n"); 但是当我写作的时候 reg.indexIn(con

我的程序从comandline获取配置。comandline是这样的: mapPath=此处上方的某些路径\n路径路径=此处上方的其他路径\n 请注意中间和结尾的\n。

我的理由是:

QString config("mapPath=Some_Path_Over_Here\npluginsPath=Other_Path_Over_Here\n")
QRegExp reg("mapPath=(.*)\\npluginsDir=(.*)\\n");
但是当我写作的时候

reg.indexIn(config)
结果是-1

重要的是,我认为我的程序同时适用于linux和windows。 我认为导致问题的原因是\n。。我不知道怎么处理。请帮助?< /P> < P> CONFIG包含两个行输入字符ASCII 0x0a,用C++文字作为\n写,但是您试图将它们与正则表达式\n n个字符匹配,ASCII 0x5C 0x6e,用C++文字写为\n。这无法工作-请将正则表达式也更改为\n


记住,把n转换成换行符是C++解析器的任务;正则表达式不会这样做。

当示例字符串具有Path时,尝试匹配包含Dir的字符串。那是打字错误吗?是的,对不起。。我会修好的