From: Cheyne Li Date: 2008-05-30T06:44:13+09:00 Subject: Re: Is there a easy way to find and replay a match Thanks a lot, it really helped. But I don't know why if i use regular expression to match the pattern "aaa=.*", it's not working with sub, but gsub. Tor Erik Linnerud wrote: > Cheyne Li wrote: >> I need "aaa=4" in the file instead of just print out > > File.open('somefile', 'r+') do |file| > content = file.read.sub('aaa=100', 'aaa=4') > file.seek(0) > file.write(content) > } > > Read more about File at > http://www.ruby-doc.org/core/classes/File.html > > although this documentation isn't the easiest to follow. > > Tor Erik -- Posted via http://www.ruby-forum.com/.