Search the Community
Showing results for tags '_stringbetween()'.
-
I'm having trouble trying to collect data that's inside an html tag, I haven't found a solution to it yet. If you have ideas please help. Thank you Script: #include <String.au3> Global $HTML_Test $HTML_Test &= '<div class="accordion-item">' & @CRLF ; <!---- START GET--> $HTML_Test &= ' <div class="accordion-inner">' & @CRLF $HTML_Test &= ' <p>Khoá an toàn giúp bếp luôn được an toàn</p>' & @CRLF $HTML_Test &= ' </div>' & @CRLF $HTML_Test &= ' <a href="#" class="accordion-title plain">' & @CRLF $HTML_Test &= ' <button class="toggle">' & @CRLF $HTML_Test &= ' <i class="icon-angle-down"></i>' & @CRLF $HTML_Test &= ' </button>' & @CRLF $HTML_Test &= ' <span>Khoá an toàn</span>' & @CRLF $HTML_Test &= ' </a>' & @CRLF $HTML_Test &= '</div>' & @CRLF ;<!---- END GET --> Global $aSearch = _StringBetween($HTML_Test, '<div class="accordion-item">', '</div>') If IsArray($aSearch) Then For $i = 0 To UBound($aSearch) - 1 ConsoleWrite('!-> SB Return: ' & $aSearch[$i] & @CRLF) Next Else ConsoleWrite('! SB: No strings found. ' & @CRLF) EndIf Unexpected output: <div class="accordion-inner"> <p>Khoá an toàn giúp bếp luôn được an toàn</p> Input: <div class="accordion-item"> <div class="accordion-inner"> <p>Khoá an toàn giúp bếp luôn được an toàn</p> </div> <a href="#" class="accordion-title plain"> <button class="toggle"> <i class="icon-angle-down"></i> </button> <span>Khoá an toàn</span> </a> </div> Desired output: <div class="accordion-inner"> <p>Khoá an toàn giúp bếp luôn được an toàn</p> </div> <a href="#" class="accordion-title plain"> <button class="toggle"> <i class="icon-angle-down"></i> </button> <span>Khoá an toàn</span> </a>
-
I would like to take String Between of the text, on starting point and end point found. #include <String.au3> Local $begin = "((" Local $end = "))" Local $loop = 0 For $i = 1 To 2 While 1 $loop += 1 $begin &= "(" If $loop = $i Then ExitLoop WEnd $loop = 0 While 1 $loop += 1 $end &= ")" If $loop = $i Then ExitLoop WEnd Local $keyS = "#", $keyE = "@" Local $0 = "A))" & $begin & $keyS & "(" & $end & $begin & $begin & "C" & $end & $begin & $end & ")" & $keyE & $end & "(((B" Local $A = _StringBetween($0, $keyS, $keyE) Local $C = $keyS & $A[0] & $keyE Local $B = _StringBetween($0, $begin, $end) Local $D = $B[0] ConsoleWrite("!-IN: " & $0 & @CRLF) ConsoleWrite("String Between: " & $begin & " <with> " & $end & @CRLF) If $C = $D Then ConsoleWrite("+OUT OK: " & $D & @CRLF & @CRLF) Else ConsoleWrite("- True result: " & $C & @CRLF) ConsoleWrite("! But OUT: " & $D & @CRLF & @CRLF) EndIf Next Local $begin = "((" Local $end = ")))" Local $loop = 0 For $i = 1 To 2 While 1 $loop += 1 $begin &= "(" If $loop = $i Then ExitLoop WEnd $loop = 0 While 1 $loop += 1 $end &= ")" If $loop = $i Then ExitLoop WEnd Local $keyS = "#", $keyE = "@" Local $0 = "A))" & $begin & $keyS & "(" & $end & $begin & $begin & "C" & $end & $begin & $end & ")" & $keyE & $end & "(((B" Local $A = _StringBetween($0, $keyS, $keyE) Local $C = $keyS & $A[0] & $keyE Local $B = _StringBetween($0, $begin, $end) Local $D = $B[0] ConsoleWrite("!-IN: " & $0 & @CRLF) ConsoleWrite("String Between: " & $begin & " <with> " & $end & @CRLF) If $C = $D Then ConsoleWrite("+OUT OK: " & $D & @CRLF & @CRLF) Else ConsoleWrite("- True result: " & $C & @CRLF) ConsoleWrite("! But OUT: " & $D & @CRLF & @CRLF) EndIf Next Local $begin = "(((" Local $end = ")" Local $loop = 0 For $i = 1 To 2 While 1 $loop += 1 $begin &= "(" If $loop = $i Then ExitLoop WEnd $loop = 0 While 1 $loop += 1 $end &= ")" If $loop = $i Then ExitLoop WEnd Local $keyS = "#", $keyE = "@" Local $0 = "A))" & $begin & $keyS & $end & "(" & $begin & $begin & "C" & $end & $begin & $end & ")" & $keyE & $end & "(((B" Local $A = _StringBetween($0, $keyS, $keyE) Local $C = $keyS & $A[0] & $keyE Local $B = _StringBetween($0, $begin, $end) Local $D = $B[0] ConsoleWrite("!-IN: " & $0 & @CRLF) ConsoleWrite("String Between: " & $begin & " <with> " & $end & @CRLF) If $C = $D Then ConsoleWrite("+OUT OK: " & $D & @CRLF & @CRLF) Else ConsoleWrite("- True result: " & $C & @CRLF) ConsoleWrite("! But OUT: " & $D & @CRLF & @CRLF) EndIf Next