_StringBetween 这个UDF很好用呀
#include<array.au3>
$str="(附属工程)"&@CRLF & _
"办公楼"& @CRLF & _
"商务部"& @CRLF & _
"写字楼"& @CRLF & _
"(住宅楼)"& @CRLF & _
"高利贷"& @CRLF & _
"商务楼"& @CRLF & _
"(商业部)"& @CRLF & _
"商场"& @CRLF & _
"菜市场"
$re=_StringBetween($str,"(",")")
_ArrayDisplay($re)
Func _StringBetween($sString, $sStart, $sEnd, $iMode = $STR_ENDISSTART, $fCase = False)
; Set mode
If $iMode <> $STR_ENDNOTSTART Then $iMode = $STR_ENDISSTART
; Set correct case sensitivity
If $fCase = Default Then
$fCase = False
EndIf
Local $sCase = "(?is)"
If $fCase Then
$sCase = "(?s)"
EndIf
; If starting from beginning of string
$sStart = $sStart ? "\Q" & $sStart & "\E" : "\A"
; If ending at end of string
If $iMode = $STR_ENDISSTART Then
; Use lookahead
$sEnd = $sEnd ? "(?=\Q" & $sEnd & "\E)" : "\z"
Else
; Capture end string
$sEnd = $sEnd ? "\Q" & $sEnd & "\E" : "\z"
EndIf
Local $aReturn = StringRegExp($sString, $sCase & $sStart & "(.*?)" & $sEnd, $STR_REGEXPARRAYGLOBALMATCH)
If @error Then Return SetError(1, 0, 0)
Return $aReturn
EndFunc ;==>_StringBetween
|