Results 1 to 3 of 3

Thread: [RESOLVED] String Split

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Resolved [RESOLVED] String Split

    I am trying to delete all parts of string after first occurence of '(' in the string
    Thought I had it earlier it but I didnt test it properly

    HTML Code:
    Dim Str As String = TextBox1.Text
            Dim words() As String = Str.Split(New [Char]() {"("c}, System.StringSplitOptions.None)
            Dim lastWord As String = words(words.Length - 2)
    Does not work when I have two occurences of '(' in string

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: String Split

    You don't need to split your string. You just find the position of the first ( in it and take a left substring from it.
    Code:
    Dim Str As String = TextBox1.Text
    Str = Str.Substring(0, Str.IndexOf("("))

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: String Split

    Quote Originally Posted by cicatrix View Post
    You don't need to split your string. You just find the position of the first ( in it and take a left substring from it.
    Code:
    Dim Str As String = TextBox1.Text
    Str = Str.Substring(0, Str.IndexOf("("))
    Thank you

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