Results 1 to 4 of 4

Thread: [RESOLVED] How to take string

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2008
    Location
    Macedonia
    Posts
    188

    Resolved [RESOLVED] How to take string

    Code:
    #EXTM3U
    #EXTINF:216,Tose Proeski i Antonija Sola - Volim osmeh tvoj
    Tose Proeski i Antonija Sola - Volim osmeh tvoj.mp3
    #EXTINF:303,Too Short - The Ghetto
    Too Short - The Ghetto.mp3
    #EXTINF:22263,get low
    get low.mp3
    #EXTINF:2812,Tracy W. Bush, Derek Duke, Jason Hayes & Glenn Stafford - Power of the Horde
    09_-_power_of_the_horde(2).mp3
    How do i get only the numbers (numbers writen in red).
    MACEDONIA 4EVER

  2. #2
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: How to take string

    1. Read the file line by line
    2. If the line starts with the string "#EXTINF:" then process it further, otherwise continue with the next line.
    3. Use the IndexOf method to find the index of the first comma "," in the line.
    4. Use the SubString method to extract the part you need (which is: between the end of the string "#EXTINF:" and the comma).

    I've underlined keywords you might want to look up (google / msdn).

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2008
    Location
    Macedonia
    Posts
    188

    Re: How to take string

    Tnx that help me so much.
    MACEDONIA 4EVER

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: [RESOLVED] How to take string

    it's easier using regex. this will return just the numbers in order of occurrence:

    vb Code:
    1. Dim testStr As String = "#EXTM3U" & Environment.NewLine & _
    2.                                 "#EXTINF:216,Tose Proeski i Antonija Sola - Volim osmeh tvoj" & Environment.NewLine & _
    3.                                 "Tose Proeski i Antonija Sola - Volim osmeh tvoj.mp3" & Environment.NewLine & _
    4.                                 "#EXTINF:303,Too Short - The Ghetto" & Environment.NewLine & _
    5.                                 "Too Short - The Ghetto.mp3" & Environment.NewLine & _
    6.                                 "#EXTINF:22263,get low" & Environment.NewLine & _
    7.                                 "get low.mp3" & Environment.NewLine & _
    8.                                 "#EXTINF:2812,Tracy W. Bush, Derek Duke, Jason Hayes & Glenn Stafford - Power of the Horde" & Environment.NewLine & _
    9.                                 "09_-_power_of_the_horde(2).mp3"
    10.  
    11. Dim rx As New Regex("(?<=\#EXTINF\:)\d+")
    12. For Each m As Match In rx.Matches(testStr)
    13.     MsgBox(m.Value)
    14. Next

    don't forget to import regex:

    vb Code:
    1. Imports System.Text.RegularExpressions

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