Results 1 to 3 of 3

Thread: Read txt file between symbols

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2009
    Posts
    5

    Read txt file between symbols

    I am working on a program, and need a way to store data. So I was thinking of making a text file like so.

    name:david:lastname: offerman:

    So I need it to read in between name: and :

    Or if someone could walk me through how to read XML that would be great and better.
    Last edited by daveoffy; Nov 28th, 2009 at 08:14 AM. Reason: Smilily showed up

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Read txt file between symbols

    i'd use a text file + regex:

    vb Code:
    1. Dim testStr As String = "name:david:lastname:offerman:"
    2. Dim rx As New Regex("(?<=name\:).+?(?=\:)")
    3.        
    4. For Each m As Match In rx.Matches(testStr)
    5.     MsgBox(m.Value)
    6. Next

    don't forget to import regex:

    vb Code:
    1. Imports System.Text.RegularExpressions

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2009
    Posts
    5

    Re: Read txt file between symbols

    Thank you SO much. This did the trick, but I should of thought better about lastname since it comes up, But I changed it to last so its all good. Thanks.

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