From: Bill Kelly Date: 2002-09-11T01:44:13+09:00 Subject: Re: Quick questions on using regular expressino with gsub... Hi, From: "Kurt Euler" > > Experts- Naw, prolly not. But I'll respond anyway ;) > Quick question: I'm trying to use the regular expression "\d" to > replace the characters "SP" followed by any single digit, with > "SP" followed by the value in a string variable. However, this > technique doesn't appear to make the desired replacements: > > pkg_base_temp.gsub!(/SP\d/, "SP"+sp_num_step) > > is the target string "/SP\d/" not written correctly? It appears to work here on ruby 1.6.6 (2001-12-26) [i586-mswin32] - irb(main):001:0> pkg_base_temp = " SP1 " " SP1 " irb(main):002:0> sp_num_step = "2" "2" irb(main):003:0> pkg_base_temp.gsub!(/SP\d/, "SP"+sp_num_step) " SP2 " irb(main):004:0> pkg_base_temp " SP2 " Regards, Bill