James Gray wrote:
> On Feb 12, 2006, at 10:18 AM, Zdebel wrote:
> 
>> 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:
>> "<lyrics artist=XXX album=XXX title=XXX> Lalalalala </lyrics>" how  
>> can I
>> cut the " artist=XXX album=XXX title=XXX" part, so it would look like:
>> "<lyrcis> Lalalalala </lyrics>" Could you please help me ?
> 
> You can do it with a regular expression like the following, but I
> must stress that this isn't very robust:
> 
>  >> "<lyrics artist=XXX album=XXX title=XXX> Lalalalala </lyrics>".sub
> (/<(\w+)[^>]+>/, "<\\1>")
> => "<lyrics> Lalalalala </lyrics>"
> 
> Hope that helps.
> 
> James Edward Gray II

:O, wow it works, I wish I knew how this (/<(\w+)[^>]+>/, "<\\1>") 
regular expresion works :). Anyway thank you, you helped me very much.

-- 
Posted via http://www.ruby-forum.com/.