From: Peter Bailey Date: 2007-08-20T22:45:11+09:00 Subject: Re: regex not gsubbing for me. Stefan Rusterholz wrote: > 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. >> >> Thanks a lot, >> Peter > > Your operation changes the string object in memory. Not the file. You > have to write the string back to the file to have it changed there. > > Regards > Stefan Thanks. Yeh, I'm doing that actually. Obviously, this is just a snipped of my code. I do this at the end of the script: File.open("F:/workflows/text/in/lobbying/temp/newfile.sgm", "w") { |f| f.print xmlfile } But, this little code line above is just one of many code lines just like it. It's just converting one thing and the others are converting other things. And, . . ., they're all working! -- Posted via http://www.ruby-forum.com/.