From: Phillip Gawlowski Date: 2011-07-21T03:27:23+09:00 Subject: Re: Splitting strings On Wed, Jul 20, 2011 at 8:16 PM, Ryan Mckenzie wrote: > > Ok, taking on board all what has been said so far... this is what I'm > hoping to achieve (short term help needed as I am a beginner) is take a > list of strings from a text file Check File#read (either "ri File#read" on the command line, or on ruby-doc.org). The gist: data = File.read "myfile" > and run through each string and split it in as many combinations as possible There's a lot of splitting possible! Though, I guess you want to split a sentence into its words, correct? Either way, String#split is what you want (probably 'A string".split(" ")', which splits the string at spaces). >, then count all the occurences of each new strings that are split and provide them in the console as an > output. Well, once you split your string, you get an Array of chunks (or tokens, if you prefer): ["A", "string"]. So the question is: Do you want to get every possible combination, or a subset of these combinations (as in the example provided in your OP)? -- Phillip Gawlowski phgaw.posterous.com | twitter.com/phgaw | gplus.to/phgaw A method of solution is perfect if we can forsee from the start, and even prove, that following that method we shall attain our aim.               -- Leibniz