Modify

Opened 11 years ago

Closed 11 years ago

#2460 closed Bug (Fixed)

_StringBetween bug when $sStart = $sEnd

Reported by: jchd18 Owned by: Jpm
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 Changed 11 years ago by Jpm

  • Milestone set to 3.3.9.22
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [9009] in version: 3.3.9.22

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.