仔细看帮助:
;选项 1, 使用偏移量
$nOffset = 1
While 1
$array = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '<(?i)test>(.*?)</(?i)test>', 1, $nOffset)
If @error = 0 Then
$nOffset = @extended
Else
ExitLoop
EndIf
for $i = 0 to UBound($array) - 1
msgbox(0, "正则表达式选项 1 测试 " & $i, $array[$i])
Next
WEnd
;选项 2, 单返回, php/preg_match() 样式
$array = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '<(?i)test>(.*?)</(?i)test>', 2)
for $i = 0 to UBound($array) - 1
msgbox(0, "正则表达式选项 2 测试 " & $i, $array[$i])
Next
;选项 3, 全程返回, 旧的 AutoIt 样式
$array = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '<(?i)test>(.*?)</(?i)test>', 3)
for $i = 0 to UBound($array) - 1
msgbox(0, "正则表达式选项 3 测试 " & $i, $array[$i])
Next
;选项 4, 全程返回, php/preg_match_all() 样式
$array = StringRegExp('F1oF2oF3o', '(F.o)*?', 4)
for $i = 0 to UBound($array) - 1
$match = $array[$i]
for $j = 0 to UBound($match) - 1
msgbox(0, "正则表达式选项 4 测试 " & $i & ',' & $j, $match[$j])
Next
Next |