Trong Posted January 7, 2016 Share Posted January 7, 2016 (edited) I would like to take String Between of the text, on starting point and end point found.expandcollapse popup#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 Edited January 7, 2016 by Trong Regards, Link to comment Share on other sites More sharing options...
careca Posted January 7, 2016 Share Posted January 7, 2016 (edited) I see what you mean, it doesn't output what's in between what you state.It's a mess, so many characters gave a knot in my brain.Simplify. Edited January 7, 2016 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
RyukShini Posted January 7, 2016 Share Posted January 7, 2016 I have recently been in need of the _StringBetween function. $read = FileRead("FILENAME.html") ;read file $Datastring = ('today_live">') $readamount = _StringBetween($read,$Datastring, "</span>") ;read title from file MsgBox(0,"",$readamount) ;display first found stringHope this helps you? Link to comment Share on other sites More sharing options...
mikell Posted January 7, 2016 Share Posted January 7, 2016 I see what you meanLucky you...Personally I DON'T see what the OP means Link to comment Share on other sites More sharing options...
Trong Posted January 7, 2016 Author Share Posted January 7, 2016 (edited) Thank for the suggestions, but I know the _StringBetween() work.I need is somethink other, and I has solved this problem!EG: #include <String.au3> Local $sString = "<test>C</test><test>B</test><test>A</test>" ConsoleWrite("+ String: " & $sString & @CRLF) ConsoleWrite("- Get string between : '<test>' and '</test>'" & @CRLF) Local $aArray = _StringBetween($sString, "<test>", "</test>", 3) For $i = 0 To UBound($aArray) - 1 ConsoleWrite("-OUT: " & $aArray[$i] & @CRLF) Next ConsoleWrite("- I do not need it! " & @CRLF) ConsoleWrite("! I need taken: C</test><test>B</test><test>A" & @CRLF & @CRLF)Solved:expandcollapse popup#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) ConsoleWrite("!-IN: " & $0 & @CRLF) ConsoleWrite("String Between: " & $begin & " <with> " & $end & @CRLF) If $C = $B Then ConsoleWrite("+OUT OK: " & $B & @CRLF & @CRLF) Else ConsoleWrite("- True result: " & $C & @CRLF) ConsoleWrite("! But OUT: " & $B & @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) ConsoleWrite("!-IN: " & $0 & @CRLF) ConsoleWrite("String Between: " & $begin & " <with> " & $end & @CRLF) If $C = $B Then ConsoleWrite("+OUT OK: " & $B & @CRLF & @CRLF) Else ConsoleWrite("- True result: " & $C & @CRLF) ConsoleWrite("! But OUT: " & $B & @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) ConsoleWrite("!-IN: " & $0 & @CRLF) ConsoleWrite("String Between: " & $begin & " <with> " & $end & @CRLF) If $C = $B Then ConsoleWrite("+OUT OK: " & $B & @CRLF & @CRLF) Else ConsoleWrite("- True result: " & $C & @CRLF) ConsoleWrite("! But OUT: " & $B & @CRLF & @CRLF) EndIf Next ; #FUNCTION# ==================================================================================================================== ; Name ..........: StringBetween ; Description ...: Find strings between two string delimiters ; Syntax ........: StringBetween($sString, $sStart, $sEnd) ; Parameters ....: $sString - The string to search. ; Parameters ....: $sStart - The beginning of the string to find. ; $sEnd - The end of the string to find. ; Return values .: Success: a found string ; Failure: sets the @error flag to non-zero. ; @error: 1 - No strings found. ; Author ........: Trong ; Related .......: _StringBetween ; Example .......: Yes ; =============================================================================================================================== Func StringBetween($sString, $sStart, $sEnd) $sString = StringReverse(StringTrimLeft($sString, StringInStr($sString, $sStart) + StringLen($sStart) - 1)) $sString = StringReverse(StringTrimLeft($sString, StringInStr($sString, StringReverse($sEnd)) + StringLen($sEnd) - 1)) Return SetError(StringLen($sString) = "", 0, $sString) EndFunc ;==>StringBetween Edited January 7, 2016 by Trong Regards, Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now