Sign in to follow this  
Followers 0
MarBobley

problem with stringsplit and stringinstr

3 posts in this topic

hi

i want to split an text at every line or at "<TR>" and then give out a line were i found a string by stringinstr.

but my code doesnt work :-(

#include <Array.au3>

$text = "<TR><TD><A class=player>Geber: </A>cissou13360 setzt 6</TD></TR><TR><TD><A class=player>Geber: </A>massimo3347 erhöht auf 12</TD></TR><TD><A class=player>Geber: </A>lastman64 geht mit bei 12</TD></TR><TR><TD><A class=player>Geber: </A>kabilos geht mit bei 12</TD></TR><TR><TD><A class=player>Geber: </A>Maris333 passt</TD></TR><TR><TD><A class=player>Geber: </A>andrewcaldw geht mit bei 12</TD></TR><TR><TD><A class=player>Geber: </A>cissou13360 erhöht auf 18</TD></TR>"


    StringReplace($text,"<TR>","|")
    $textarray = StringSplit($text,"|")
    MsgBox(0,"",$textarray[0])
    _ArrayReverse($textarray)
    For $i = 0 To UBound($textarray) - 1 Step + 1
        If StringInStr($textarray[$i],"massimo") = 1 Then
            MsgBox("0","",$textarray[$i])
            ExitLoop
        EndIf
    Next

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Your StringInstr() test tests for the word "massimo" starting on position 1, not anywhere in the string.

Your test should be:

If StringInStr($textarray[$i], "massimo") > 0 Then

or

If StringInStr($textarray[$i], "massimo") Then

also this line should be:

$text = StringReplace($text, "<TR>", "|")

Jos muttley

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

works fine! thx!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0