Modify

Opened 12 years ago

Closed 12 years ago

#2460 closed Bug (Fixed)

_StringBetween bug when $sStart = $sEnd

Reported by: jchd18 Owned by: J-Paul Mesnage
Milestone: 3.3.9.22 Component: Standard UDFs
Version: 3.3.9.21 Severity: None
Keywords: Cc:

Description

Local $aRes = _StringBetween("abbbaccca", "a", "a")
; "bbb" is between "a" and "a" and is returned OK
; "ccc" is also between "a" and "a" but is not returned _ArrayDisplay($aRes)

I propose the following change to fix this case:

Local $aRes = _StringBetween("abbbaccca", "a", "a")
; "bbb" is between "a" and "a"
; "ccc" is also between "a" and "a" and is now returned
_ArrayDisplay($aRes)

; #FUNCTION# ====================================================================================================================
; Author ........: SmOke_N (Thanks to Valik for helping with the new StringRegExp (?s)(?i) issue)
; Modified.......: SmOke_N - (Re-write for speed and accuracy), jchd
; ===============================================================================================================================
Func _StringBetween($sString, $sStart, $sEnd, $fCase = Default)
	Local $sCase = "(?" & ($fCase ? "i" : "") & "s)"

	; If you want data from beginning then replace blank start with beginning of string
	$sStart = $sStart ? "\Q" & $sStart & "\E" : "\A"

	; If you want data from a start to an end then replace blank with end of string
	$sEnd = $sEnd ? "(?=\Q" & $sEnd & "\E)" : "\z"

	Local $aReturn = StringRegExp($sString, $sCase & $sStart & "(.*?)" & $sEnd, 3)
	If @error Then Return SetError(1, 0, 0)
	Return $aReturn
EndFunc   ;==>_StringBetween

Attachments (0)

Change History (1)

comment:1 by J-Paul Mesnage, 12 years ago

Milestone: 3.3.9.22
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [9009] in version: 3.3.9.22

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.