求个正则表达式【已解决】感谢a版
本帖最后由 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
#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), '其中元素为: ' & $aSRE)
_ArrayDisplay($aSRE, UBound($aSRE))
本帖最后由 fybhwsx 于 2023-4-20 20:36 编辑
afan 发表于 2023-4-20 20:24
感谢a版!
本帖最后由 holley 于 2023-4-21 12:50 编辑
手痒,试了一下,包括前面的张三,共5个捕获组,每1个都匹配到了
([\u4e00-\u9fa5]+).+?(\d+-\d+-\d+).+?([\d\.]+).+?([\d\.]+).+?([\d\.]+),,.*https://cdn.jsdelivr.net/gh/master-of-forums/master-of-forums/public/images/patch.gif 一直看不懂正则,看来需要花时间来学习学习。
页:
[1]