From: ben baka Date: 2008-02-04T21:35:00+09:00 Subject: Re: Strings .each method ------=_Part_5995_646821.1202128503103 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I think this might. string = "This is a big old string" #Instead of iterating you could match text "big" find = string.match('big') #to see if "big" is in the next block of the sentence do this. puts find.post_match.match('old') Thanks. On Feb 3, 2008 2:09 AM, Ken Bloom wrote: > On Sat, 02 Feb 2008 17:14:26 -0500, Chris Hickman wrote: > > > Corey Haines wrote: > >> but if you can describe why you want to do it, there might be a > >> different way > > > > It is kind of hard to explain but I have a long string that someone > > typed into a form which was then saved into a database. They used made > > up tags such as ", , , , ..." I > > have to translate the string into html and add javascript etc. based on > > the different tags they wrote. > > > > I have it working for everything except one task. In this one task I > > want to pass the words between two tags as a value for the javascript. > > The problem is it is pulling the phrase apart at every space. I know I > > can add .each(???) and have it pull everything apart at the ??? but it > > would involve a lot of adding ??? to this long string. > > > > What I am trying to do is add a while loop inside the block that will > > look ahead at the next substring to see if it is a "". If it > > is I want it to exit the while loop and go on without throwing away the > > "" tag because it is needed next time through the block. > > > > Sorry if that didnt make sense at all. > > Might I suggest that using REXML (or another XML parser) may make more > sense for what you're trying to do? First navigate your way through the > tag structure, then you can get the text elements that you're trying to > find. > > > > -- > Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory. > Department of Computer Science. Illinois Institute of Technology. > http://www.iit.edu/~kbloom1/ > > -- --Ben Baka Blog : http://benjaminbaka.wordpress.com/ ------=_Part_5995_646821.1202128503103--