Modify

Opened 9 years ago

Closed 8 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 Changed 8 years ago by trancexx

  • Component changed from AutoIt to Standard UDFs

comment:2 Changed 8 years ago by guinness

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

comment:3 Changed 8 years ago by guinness

  • Resolution set to Works For Me
  • Status changed from new to closed

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

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 ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.