全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 393|回复: 1

[Windows VPS] 求助一个应该很简单的C++正则匹配的问题!

[复制链接]
发表于 2018-12-26 17:38:39 | 显示全部楼层 |阅读模式
这个是要匹配的文本的原文:




Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
(...省略一点...)
Ping statistics for 127.0.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 0ms, Average = 233ms



我想匹配到平均延迟(也就是average=233ms的地方)。写的表达式是:Average.([0-9]+)ms
确实可以匹配到Average=223ms。但是c++好像对其他语言里正则的小括号免疫??我要怎么才能直接拿到233这三个数字?

下面是代码:




regex reg1("Average.([0-9]+)ms");
        string s2 = status;
        cout << "iterator结果:";
        sregex_iterator it(s2.begin(), s2.end(), reg1);
        sregex_iterator end;
                for (; it != end; ++it)
                {
                        cout<< it->str() << endl;
                }




IDE是VS2017,求大佬指点迷津_(:з」∠)_ 而且为啥c++都不认类似e.=.([0-9])+ms的表达?
image.png (24.91 KB, 下载次数: 1)
明明Java和php下都能通过,c++就不行。

快过年了,祝各位大佬万事如意!


发表于 2018-12-26 18:00:10 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-23 22:09 , Processed in 0.062191 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表