BlueNachid icon

String Array Between Function

BlueNachid | PRO | 12/18/15 05:06:40 PM UTC | 0 ⭐ | 12332 👁️ | Never ⏰ | []
AutoIt |

1.32 KB

|

None

|

0 👍

/

0 👎

#cs
Simply put in ur $string, the $start where u wanna $start capturing and the $end.
Like this
 
$string = "<h1 class='someclass'>The 'data'  i want</h1>"
$start = "<h1 class='someclass'>"
$end = "</h1>"
 
and u will recive "The 'data' i want".
 
You can even querry a array out of any text with this function.
$string = "<h1 class='someclass'>The 'data'  i want</h1>"
$start = "'"
$end = "'"
 
If you put in this the return would be
 
[0] someclass
[1] data
 
Thank you for using my work.
BTW : please Test for StrInStr. If it not appears ull recive a error.
#ce
 
 
Func between($string, $start, $end, $array = 0)
    If $array = 0 Then
        $string = StringSplit($string, $start, 1)
        If $string[0] < 2 Then Return 0
        $string = $string[2]
        $string = StringSplit($string, $end, 1)
        If @error = 1 Then Return 0
        $string = $string[1]
        Return $string
    Else
        Local $startstring = StringSplit($string, $start, 1)
        Local $nextsplitt[1]
        For $i = 2 To $startstring[0] Step +1
            If $i <= $startstring[0] Then
                _ArrayAdd($nextsplitt, $startstring[$i])
            EndIf
        Next
        Local $returner[1]
        For $i = 1 To UBound($nextsplitt) - 1
            Local $rs = StringSplit($nextsplitt[$i], $end, 1)
            _ArrayAdd($returner, $rs[1])
        Next
        Return $returner
    EndIf
;Function by Nachid - U3C0
;schindler-it.org
EndFunc   ;==>between

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎