Modify

Opened 14 years ago

Closed 14 years ago

#2149 closed Bug (Works For Me)

_StringBetween does not accept NULL-chars in the boundary strings

Reported by: anonymous Owned by:
Milestone: Component: Standard UDFs
Version: 3.3.9.1 Severity: None
Keywords: Cc:

Description

When using NULL-characters in the start or end string, _StringBetween does not work. The following version is fixed:

Func _StringBetween($s_String, $s_Start, $s_End, $v_Case = -1)

    ; Set case type
    Local $s_case = ""
    If $v_Case = Default Or $v_Case = -1 Then $s_case = "(?i)"

    ; Escape characters
    Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\|\0)"
    $s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1")
    $s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1")

    ; If you want data from beginning then replace blank start with beginning of string
    If $s_Start = "" Then $s_Start = "\A"

    ; If you want data from a start to an end then replace blank with end of string
    If $s_End = "" Then $s_End = "\z"

    Local $a_ret = StringRegExp($s_String, "(?s)" & $s_case & $s_Start & "(.*?)" & $s_End, 3)

    If @error Then Return SetError(1, 0, 0)
    Return $a_ret
EndFunc   ;==>_StringBetween

Attachments (0)

Change History (3)

comment:1 by trancexx, 14 years ago

Component: AutoItStandard UDFs

comment:2 by guinness, 14 years ago

Please provide an example that doesn't work for you.

comment:3 by guinness, 14 years ago

Resolution: Works For Me
Status: newclosed

Please read how to 'create a ticket', as you've failed to provide a small test script.

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


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