From: Alex Young Date: 2007-08-20T22:20:02+09:00 Subject: Re: regex not gsubbing for me. Peter Bailey wrote: > Hi, > Can someone please explain to me why this simple regex substitution > won't work? > > Source data file: > Reauthorization of collaborative weather modification > research program within Department of Commerce/NOAA Weather modification > research appropriations > > My script line: > xmlfile.gsub!(/(.*)<\/purpose>/mi, ' face="b">Purpose: \1') > > The data stays the same. The line isn't converted. It works for me... irb(main):001:0> a = "Reauthorization of collaborative weather modification irb(main):002:0" research program within Department of Commerce/NOAA Weather modification irb(main):003:0" research appropriations irb(main):004:0" " => "Reauthorization of collaborative weather modification\nresearch program within Department of Commerce/NOAA Weather modification\nresearch appropriations\n" irb(main):005:0> a.gsub!(/(.*)<\/purpose>/mi, 'Purpose: \1') => "Purpose: Reauthorization of collaborative weather modification\nresearch program within Department of Commerce/NOAA Weather modification\nresearch appropriations\n" irb(main):007:0> a => "Purpose: Reauthorization of collaborative weather modification\nresearch program within Department of Commerce/NOAA Weather modification\nresearch appropriations\n" -- Alex