Results 1 to 4 of 4

Thread: Please help with string manipulation (parsing)..

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2002
    Posts
    628

    Please help with string manipulation (parsing)..

    Code:
    <td valign=top width=2%><b>&middot; </b></td><td valign=top width=100%><font face=arial size=-1><b><a onclick='return popup("pp121")' href="/?room=Asian%20Markets::1600382635">Asian Markets</a></b><br>discuss the latest market activity.</font></td><script>sc(15,5,0)</script></tr><tr><td>
    </td><td valign=top width=2%><b>&middot; </b></td><td valign=top width=100%><font face=arial size=-1><b><a onclick='return popup("pp200")' href="/?room=Biotechnology::1600326508">Biotechnology</a></b><br>Discuss the latest research and advances in this field.</font></td><script>sc(1,1,0)</script></tr><tr><td>
    </td><td valign=top width=2%><b>&middot; </b></td><td valign=top width=100%><font face=arial size=-1><b><a onclick='return popup("pp212")' href="/?room=Bond%20Market::1603088415">Bond Market</a></b><br>Come here to chat live about the bond market!</font></td><script>sc(2,1,0)</script></tr><tr><td>
    </td>


    There are many of these im a html source.. and theres dozens of these sequences in the source.. listing a link with a <script> tag
    beside it. how can i create a function to check the value of the 1st number in each <script>sc(x,y,z)</script> (x in this case) in
    the order it was seen in the html source?


    for example, lets say i wanted to check the value of the 3rd item in the source (in this case, the last)..
    Check(3) would return the value of 2, as "<script>sc(2,1,0)</script>" shows 2 as the first number in the 3rd time in the source.

    anyone know?
    Last edited by n00bie; Aug 4th, 2002 at 08:59 PM.

  2. #2
    Hyperactive Member ZeroCool's Avatar
    Join Date
    Feb 2002
    Location
    In front of my computer
    Posts
    423
    VB Code:
    1. Public Function Get_Info(Mystr As String, intNumber) As String
    2. Dim I As Integer
    3. Dim Tmp() As String
    4. Dim MyTmp As String
    5. Tmp = Split(mystr, "<")
    6. Do Until I = UBound(Tmp) + 1
    7. If Left(Tmp(I), 10) = "script>sc(" Then
    8. MyTmp = Tmp(I)
    9. Exit Do
    10. End If
    11. I = I + 1
    12. Loop
    13. If Not Len(MyTmp) = 0 Then
    14. MyTmp = Right(MyTmp, 7)
    15. MyTmp = Left(MyTmp, Len(MyTmp) - 1)
    16. Get_Info = Split(MyTmp, ",")(intNumber)
    17. End If
    18. End Function

    That Should do It

    'Msgbox Get_Info(String, Number)
    Visual Baisc 6 (SP5)
    Windows Xp

  3. #3
    Junior Member
    Join Date
    Feb 2002
    Posts
    23
    I'm stealing the Split idea from ZeroCool but
    I think this will give you the results you were looking for.

    You might have to get more specific with
    your Split criteria to make sure it will find the correct data everytime.
    VB Code:
    1. Public Function Get_Info(Mystr As String, intNumber) As String
    2.  
    3. Dim I As Integer
    4. Dim Tmp() As String
    5.  
    6. Tmp = Split(Mystr, "sc(")
    7. Get_Info = Val(Tmp(intNumber))
    8.  
    9. End Function
    Now

    MsgBox Get_Info("SomeString",3)

    should return what your looking for.

  4. #4
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Omaha, NE
    Posts
    270
    I, too, would use the 'Split' function (as ZeroCool & Sideout suggest), but I'd be more specific on your criteria.
    VB Code:
    1. Public Function Get_Info(Mystr As String, intNumber) As String
    2.  
    3. Dim I As Integer
    4. Dim Tmp() As String
    5.  
    6. Tmp = Split(Mystr, "[b]<script>[/b]sc(")
    7. Get_Info = Val(Tmp(intNumber))
    8.  
    9. End Function
    Nate

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width