Results 1 to 4 of 4

Thread: Very simple question - string parsing

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2002
    Posts
    628

    Very simple question - string parsing

    http://chat.yahoo.com/?room=salam ::1600000002
    http://chat.yahoo.com/?room=tanre::1600000002
    http://chat.yahoo.com/?room=texas38room::59000542

    how can you msgbox the data between ?room= and ::?

    for example, the msgboxes would contain "salam ", "yanre" and "texas38room"

    but.. the data between ?room= and :: can be anything, including charachters like ":"...

    how can i msgbox the data in the middle?

  2. #2
    Lively Member
    Join Date
    Mar 2002
    Location
    Klamath Falls, OR
    Posts
    71
    VB Code:
    1. url = Mid$(url, InStr(1, url, "room=") + 5, Len(Right$(url, InStr(1, url, ":"))))
    2. MsgBox url


    That should do it.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2002
    Posts
    628
    is it possible to use "::" in the code?

    : is kinda dangerous as it can be in the data

  4. #4
    Frenzied Member macai's Avatar
    Join Date
    Jul 2001
    Location
    Napanoch NY
    Posts
    1,228
    VB Code:
    1. 'Place this in a module:
    2. Public Function Between(Text As String, Delim1 As String, Delim2 As String, Optional Start As Long = 1) As String
    3.  Dim Z, X, Y, W
    4.  Z = InStr(Start, Text, Delim1)
    5.  X = InStr(Start, Text, Delim2)
    6.  If X > Z And Start <= Z Then
    7.   Y = Z + Len(Delim1)
    8.   W = X - Z - Len(Delim1)
    9.   Between = Mid$(Text, Y, W)
    10.  End If
    11. End Function
    VB Code:
    1. 'Usage
    2. Msgbox Between(SomeString, "?room=", "::", 1)
    I wrote this ages ago, but i just pulled it out for you.
    Luke

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