Results 1 to 6 of 6

Thread: [RESOLVED] [2005] is There a Function That do this ?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Resolved [RESOLVED] [2005] is There a Function That do this ?

    Hi ,

    The Split Function has as parameter char

    is there a way to use Split Function With String as parameter

    How ?
    let's say i have this string :
    " Hello Vb Forum members enjoy your stay at VbForums enjoy"

    i need to extract the String between enjoy
    it should be : "your stay at VbForums"

    Split("enjoy")..

    Thanks

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] is There a Function That do this ?

    You can use Regex for that:

    VB.NET Code:
    1. Dim myString As String = "The quick fox jumped over the lazy fox"
    2.         Dim reg As New System.Text.RegularExpressions.Regex("fox")
    3.         Dim mySplittedString() As String = reg.Split(myString)
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    Lively Member
    Join Date
    Oct 2007
    Posts
    64

    Re: [2005] is There a Function That do this ?

    strToSplit = Mid(strToSplit, 0, Int(strToSplit.Length / 2))

    i think that works ....

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] is There a Function That do this ?

    As atheist said, although you don't even need to create an instance of regex, there is a shared split method.

    Code:
    Dim myString As String = "The quick fox jumped over the lazy fox"        
    Dim mySplittedString() As String = System.Text.RegularExpressions.Regex.Split(myString,"fox")

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    530

    Re: [2005] is There a Function That do this ?

    Quote Originally Posted by Atheist
    You can use Regex for that:

    VB.NET Code:
    1. Dim myString As String = "The quick fox jumped over the lazy fox"
    2.         Dim reg As New System.Text.RegularExpressions.Regex("fox")
    3.         Dim mySplittedString() As String = reg.Split(myString)

    Thanks Atheist work Great

    Yes kleinma work too

    @tylerpestell
    strToSplit = Mid(strToSplit, 0, Int(strToSplit.Length / 2))

    i dont know what you mean ?

    anyway now it's working


    Thanks All

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

    Re: [RESOLVED] [2005] is There a Function That do this ?

    you can split a string With String as parameter:

    Dim myString() As String = "The quick fox jumped over the lazy fox".Split(New String() {"fox"}, StringSplitOptions.RemoveEmptyEntries)
    Last edited by .paul.; Oct 16th, 2008 at 06:34 PM.

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