二维数组:
#include <Array.au3>
Local $Str = _
'11 23pphh =11 2 不是h 或p' & @CRLF & _
'22 p9944 =22 p' & @CRLF & _
'-33 sdfh77 = -33 s 不是h 或p' & @CRLF & _
'44dfghdfh = 放弃' & @CRLF & _
'55 = 放弃 (注: 即使55 的后面带空格也要放弃)' & @CRLF & _
'66pp66 ph = 放弃 空格前的字符必须是整数' & @CRLF
MsgBox(0, '原字符串', $Str)
Local $Test = StringRegExp($str, '(?m)(^[+-]?\d*\.*\d+\b)\h([ph]|s)', 3)
If Not @Error Then MsgBox(0, '匹配数量: ' & UBound($Test), '其中[0]元素为: ' & $Test[0])
Local $Array[Int(UBound($Test)/2)][2]
For $i=0 to UBound($Test)-1 Step 2
$Array[$i/2][0]=$Test[$i]
$Array[$i/2][1]=$Test[$i+1]
Next
_ArrayDisplay($Array)
取空格后P,H,S
#include <Array.au3>
Local $Str = _
'11 23pphh =11 2 不是h 或p' & @CRLF & _
'22 p9944 =22 p' & @CRLF & _
'-33 sdfh77 = -33 s 不是h 或p' & @CRLF & _
'44dfghdfh = 放弃' & @CRLF & _
'55 = 放弃 (注: 即使55 的后面带空格也要放弃)' & @CRLF & _
'66pp66 ph = 放弃 空格前的字符必须是整数' & @CRLF
MsgBox(0, '原字符串', $Str)
Local $Test = StringRegExp($str, '(?m)^[+-]?\d*\.*\d+\b\h([phs])', 3)
If Not @Error Then MsgBox(0, '匹配数量: ' & UBound($Test), '其中[0]元素为: ' & $Test[0])
_ArrayDisplay($Test)
|