本帖最后由 3mile 于 2011-6-24 10:45 编辑
回复 7# newuser
#include <array.au3>
Local $str="this is a red fox"&@crlf& _
"this is a blue firefox"&@CRLF& _
"this is a pig"&@crlf& _
"a red fox"
Local $result=StringRegExp($str,"(?m)(?:^this is )?a (?:red fox|blue firefox|pig)",4);返回完整匹配的数组和全局匹配的数组
;~ for $temp in $result
;~ _ArrayDisplay($temp )
;~ Next
for $i=0 to UBound($result)-1
_ArrayDisplay($result[$i])
Next
#include <array.au3>
Local $str="this is a red fox"&@crlf& _
"this is a blue firefox"&@CRLF& _
"this is a pig"&@crlf& _
"a red fox"
Local $result=StringRegExp($str,"(this is )?a (red fox|blue firefox|pig)",4);返回完整匹配的数组和全局匹配的数组
;~ for $temp in $result
;~ _ArrayDisplay($temp )
;~ Next
for $i=0 to UBound($result)-1
_ArrayDisplay($result[$i])
Next
#include <array.au3>
Local $str="this is a red fox"&@crlf& _
"this is a blue firefox"&@CRLF& _
"this is a pig"&@crlf& _
"a red fox"
Local $result=StringRegExp($str,"((?m)(^this is )?a (red fox|blue firefox|pig))",3);返回完整匹配的数组和全局匹配的数组
_ArrayDisplay($result)
local $str_result
for $i=0 to UBound($result)-1 step 3;共3组,只取第一组
$str_result&=$result[$i]&@CRLF
Next
msgbox(0,0,$str_result)
|