(NEWB) Using .split()?

VB express '05 Beta

I have a large string (about 40 pages worth of data) That I need to parcel into smaller chunks, there are repeating markers in the data that I want to use as delimiters.  txtimp is the large raw string, and hand() is the string array that I want to have the data chopped into. I'm using:


stray()=txtimp.split("Data")

 


But, It is only searching for "D", not "Data".  There are frequent D's in the text, so It's giving me many smaller strings I dont want.

In the IDE, when Inputting the string I want it to search for, it gives me a list of ten choices of versions of split to use.  I always select the one that uses a string to search, but it always uses a char. 

Help! 
 
PS, The beta version's Help documentation sucks.  You type an entry to search for (non-online docs) and it comes back with random entries, Otherwwise I would figured this thing out for my self.


Answer this question

(NEWB) Using .split()?

  • Vladimir Nikitin

    Very cool, thank you...

    Been about 15 years since I coded, aside from PALM pilot coding in NSBasic, trying to catch up.  No more cin and cout stuff hehehe.....

  • zbc

    This is the VB-code:


    Dim inputstring As String = "DataabcDatadefData"

    Dim re As new System.Text.RegularExpressions.Regex("Data")

    Dim result() As String

    result = re.Split(inputstring)


     



    inputstring is your long string of data.
    result is the array of chopped strings
    "Data" is the separator.

    this code fills result with 4 strings ("",abc,def,"")



  • mfarace

    yup, you lost me.....

    Maybe instead of Split, is there VB way of doing this so it finds a string, and parses from one delimiter string to the next and sticks it in an array


  • Dave Foderick

    String.Split can use only chars as separator. Or array's of chars if you want to use multiple separators.

    You can use the Regex.Split however:



    string input = "Data1Data2Data3Data";
    Regex re = new Regex("Data");          
    string[] test = re.Split(input);         

     


    I hope you have no problems with the c# code. If you do I will translate it.



  • (NEWB) Using .split()?