Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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
Regex QRegularExpression多行与换行符不匹配_Regex_Qt - Fatal编程技术网

Regex QRegularExpression多行与换行符不匹配

Regex QRegularExpression多行与换行符不匹配,regex,qt,Regex,Qt,我需要匹配文本--BB0和--EE0之间的两行,所以我在QT中使用了这个正则表达式: QRegularExpression rx0("(--BB0\n)(.*)(\n.*--EE0)", QRegularExpression::MultilineOption | QRegularExpression::DotMatchesEverythingOption) 在这种情况下,此正则表达式正确匹配 QRegularExpressionMatch match = rx0.match(" --BB

我需要匹配文本--BB0和--EE0之间的两行,所以我在QT中使用了这个正则表达式:

QRegularExpression rx0("(--BB0\n)(.*)(\n.*--EE0)", QRegularExpression::MultilineOption | QRegularExpression::DotMatchesEverythingOption)
在这种情况下,此正则表达式正确匹配

QRegularExpressionMatch match = rx0.match("    --BB0\n    AAAA\n    BBBB\n    --EE0");
但是当我匹配实际的字符串时,它没有找到任何东西

--BB0
signal our_ip_address      : std_logic_vector (31 downto 0)  :=   x"c0a80509" ;   -- 192.168.5.9
signal our_mac_address     : std_logic_vector (47 downto 0)  :=   x"002320212223";
--EE0
我哪里做错了


谢谢

您不需要所有这些,只需使用以下表达式:

--BB0(.*?)--EE0
如果使用
QRegularExpression::dotmatcheseverything选项
,您就不需要
QRegularExpression::multileneoption
,因为您没有在正则表达式中使用
^
$

比赛将在第一组进行


您不需要所有这些,只需使用以下表达式:

--BB0(.*?)--EE0
如果使用
QRegularExpression::dotmatcheseverything选项
,您就不需要
QRegularExpression::multileneoption
,因为您没有在正则表达式中使用
^
$

比赛将在第一组进行


那么,为什么多行不起作用呢?OP是如何让那些Qt模式选项工作的?那么为什么多行不工作呢?OP如何让这些Qt模式选项工作?