From: Peter Fitzgibbons Date: 2005-07-30T20:07:25+09:00 Subject: Re: Chopping the beginning of a string elegantly -----Original Message----- From: francisrammeloo@hotmail.com [mailto:francisrammeloo@hotmail.com] Sent: Saturday, July 30, 2005 3:06 AM To: ruby-talk ML Subject: Re: Chopping the beginning of a string elegantly I'm sorry but my first post was misleading. The string actually looks like this: " BeginCaption 0, 20, 66, .." (the whitespace can be a combination of tabs and spaces) So I actually have to cut out "Caption" word in the <> of the string. Brian's hint got me on the right track. The solution I finally found was: pane = line.sub(/\s*Begin(\w+).*/, '\1') Unless some expert can prove a still more tight solution I believe I have found the best way to cut out the "Caption" part of the string. Thank you all for your help. Best regards, Francis ===================================== We go back to Kero's example, for tightness : C:\ruby\dev\buildview>irb irb(main):001:0> line = "BeginCaption 0, 22, 66, ..." => "BeginCaption 0, 22, 66, ..." irb(main):002:0> line[/Caption/] = "" => "" irb(main):003:0> line => "Begin 0, 22, 66, ..." irb(main):004:0> Peter J. Fitzgibbons Applications Manager Lakewood Homes - "The American Dream Builder"(r) Peter.Fitzgibbons@Lakewoodhomes.net (847) 884-8800