本帖最后由 仙乃日 于 2022-4-10 20:30 编辑 #include <Array.au3>
Local $sSource = _
'2022 MAR 05 08:47:54' & @CRLF & _
' NAME:ML235004' & @CRLF & _
' ID: 0-0001 (00000307)' & @CRLF & _
' LEU - neg' & @CRLF & _
' NIT - neg' & @CRLF & _
' URO - <=0.2mg/dL' & @CRLF & _
' PRO - 5mg/dL' & @CRLF & _
' PH 5.5 ' & @CRLF & _
' BLO - neg' & @CRLF & _
' SG 1.025 ' & @CRLF & _
' KET +- 5mg/dL' & @CRLF & _
'*BIL 2+ 2mg/dL' & @CRLF & _
' GLU - neg' & @CRLF & _
' ASC - neg'
Local $aSRE = StringRegExp($sSource, ' NAME:(?<grp0>[^\n]+)', 3)
If Not @Error Then MsgBox(0, '匹配数量: ' & UBound($aSRE), '其中[0]元素为: ' & $aSRE[0])
_ArrayDisplay($aSRE, UBound($aSRE))
Local $sSource = _
'2022 MAR 05 08:47:54' & @CRLF & _
' NAME:ML235005' & @CRLF & _
' ID: 0-0001 (00000307)' & @CRLF & _
' LEU - neg' & @CRLF & _
' NIT - neg' & @CRLF & _
' URO - <=0.2mg/dL' & @CRLF & _
' PRO +- neg' & @CRLF & _
' PH 5.5 ' & @CRLF & _
' BLO - neg' & @CRLF & _
' SG 1.025 ' & @CRLF & _
' KET +- 5mg/dL' & @CRLF & _
'*BIL 2+ 2mg/dL' & @CRLF & _
' GLU - neg' & @CRLF & _
' ASC - neg'
Local $aSRE = StringRegExp($sSource, 'PRO\h*([\-|\+|\d]*)\h*', 3)
If Not @Error Then MsgBox(0, '匹配数量: ' & UBound($aSRE), '其中[0]元素为: ' & $aSRE[0])
_ArrayDisplay($aSRE, UBound($aSRE))
需要将文本转换成INI文件,使用NAME:后边的条码作为节名.
[ML235004]
PRO=+-
帮忙简化一下代码
感谢各位的帮忙 |