找回密码
 加入
搜索
查看: 543|回复: 4

[网络通信] 求个正则表达式【已解决】感谢a版

[复制链接]
发表于 2023-4-20 20:17:01 | 显示全部楼层 |阅读模式
本帖最后由 fybhwsx 于 2023-4-20 20:32 编辑

张三,,693628,473980.00,239.68,0.00,0.00,0.00,0.00,0.00,0.00,0.00,100239.68,0.00,0.00,260.00,0.00,0.00,0.00%,0.00,0.000,0.000,239.68,239.68,2023-04-20,100239.68,100239.68,0.00,260.00,99879.68,0.00,0.00,100000.00,0.00,20.32,,0.00

提取:
2023-04-20
100239.68
20.32

发表于 2023-4-20 20:24:46 | 显示全部楼层
#include <Array.au3>
Local $sSource = '张三,,693628,473980.00,239.68,0.00,0.00,0.00,0.00,0.00,0.00,0.00,100239.68,0.00,0.00,260.00,0.00,0.00,0.00%,0.00,0.000,0.000,239.68,239.68,2023-04-20,100239.68,100239.68,0.00,260.00,99879.68,0.00,0.00,100000.00,0.00,20.32,,0.00'
;~ MsgBox(0, '源字符串', $sSource)
Local $aSRE = StringRegExp($sSource, '(?m)^.+?(\d+-\d+-\d+),([\d\.]+).+?([\d\.]+),[\d\.]*,[\d\.]*$', 3)
If Not @Error Then MsgBox(0, '匹配数量: ' & UBound($aSRE), '其中[0]元素为: ' & $aSRE[0])
_ArrayDisplay($aSRE, UBound($aSRE))

评分

参与人数 1金钱 +40 收起 理由
fybhwsx + 40 很给力!

查看全部评分

 楼主| 发表于 2023-4-20 20:28:33 | 显示全部楼层
本帖最后由 fybhwsx 于 2023-4-20 20:36 编辑
感谢a版!
发表于 2023-4-21 12:49:54 | 显示全部楼层
本帖最后由 holley 于 2023-4-21 12:50 编辑

手痒,试了一下,包括前面的张三,共5个捕获组,每1个都匹配到了
([\u4e00-\u9fa5]+).+?(\d+-\d+-\d+).+?([\d\.]+).+?([\d\.]+).+?([\d\.]+),,.*
发表于 2023-4-24 10:33:46 | 显示全部楼层
一直看不懂正则,看来需要花时间来学习学习。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-22 11:05 , Processed in 0.081071 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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