PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2010 Advanced string parser-VBForums
Results 1 to 4 of 4

Thread: Advanced string parser

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    3

    Advanced string parser

    Hello. Needing your help..
    I have textbox1.text ( multiline) that is filled with data from a external .txt file. On each line of textbox1.text i have the folowing data:

    50ABCDEFGHIhsfgsdf60JKLMNOJ55JK4

    I need a way to display in my second textbox ( textbox2.text - multiline also) on each line the fallowing data:
    "NUMBER1" & ABCDEFGHI & "NUMBER2" & JKLMNO
    So basically i need to find the "50" string,remove it, read "9" characters after it, same goes with 60 and JKLMNO
    I have a undefined non-fix numbers of lines in textbox.text1 !
    Hope somebody understands what i want and could give me a help . Maria

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

    Re: Advanced string parser

    shouldn't that 2nd string be JKLMNOJ?

  3. #3
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: Advanced string parser

    its not string parsing that you want to do, parsing converts a string equivilent to some type i.e. Date Integer etc...

    You want to remove remove parts of a string, not sure what version you have but here is a link that will help you, also want to look at the SubString method

    http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx

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

    Re: Advanced string parser

    you could use regex:

    vb Code:
    1. Imports System.Text.RegularExpressions
    2.  
    3. Public Class Form1
    4.  
    5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.         Dim s As String = "50ABCDEFGHIhsfgsdf60JKLMNOJ55JK4"
    7.         Dim rx As New Regex("(\d+)([A-Z]+)")
    8.         Dim number1 As Integer = CInt(rx.Matches(s)(0).Groups(1).Value)
    9.         Dim firstString As String = rx.Matches(s)(0).Groups(2).Value
    10.         Dim number2 As Integer = CInt(rx.Matches(s)(1).Groups(1).Value)
    11.         Dim secondString As String = rx.Matches(s)(1).Groups(2).Value
    12.  
    13.     End Sub
    14. End Class

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width