From: James Edward Gray II Date: 2006-02-13T02:14:04+09:00 Subject: Re: Cutting a piece of text On Feb 12, 2006, at 11:05 AM, David Vallner wrote: > Dňa Nedeľa 12 Február 2006 17:18 Zdebel napísal: >> Helo ! >> I've started to learn ruby and I'm amazed with it. Now I have a >> problem >> that I can't solve. If I have a string like this: >> " Lalalalala " how >> can I >> cut the " artist=XXX album=XXX title=XXX" part, so it would look >> like: >> " Lalalalala " Could you please help me ? > > The very geeky, and most probably least error-prone way would be > whacking the > string with a DOM parser, clearing the attributes, and then > printing it out > again. Unfortunately, I haven't been doing any DOM manipulation in > Ruby, so I > can't provide code. The following is how you do it for valid XML, but the posted example wasn't quite: #!/usr/local/bin/ruby -w require "rexml/document" doc = " Lalalalala " xml = REXML::Document.new(doc) xml.root.attributes.clear xml.write puts __END__ James Edward Gray II