From: "David A. Black" Date: 2010-06-03T19:19:07+09:00 Subject: Re: gsub with wildcard Hi -- On Thu, 3 Jun 2010, Dhruva Sagar wrote: > On Thu, Jun 3, 2010 at 15:40, Reinhart Viane wrote: > >> Hello, >> >> >> >> I want to replace: >> >> >> >> id="idxxxxxxx" with id="id20" >> >> in a string >> >> >> >> I know this can be done with gsub but I don't know how to use wildcards. >> >> The xxxxxxx can be of any length but only numbers >> > This should do - string.gsub(/\d+/, '20') That's a bit over-eager; it will change any sequence of digits anywhere in the string. David -- David A. Black, Senior Developer, Cyrus Innovation Inc. THE Ruby training with Black/Brown/McAnally COMPLEAT Coming to Chicago area, June 18-19, 2010! RUBYIST http://www.compleatrubyist.com