Ahmet Kilic wrote: > Rodrigo Bermejo wrote: >> >>> >>> To write to a file you need something like this: >>> f=File.new("w","myfile.txt") >>> f << "line 1" >>> f << "line 2" >>> f.close >> Sorry it should be filename, mode ..this way is the correct. >> f=File.new("myfile.txt","w) > > It is OK. Thank you very much. > I don't want to print the whole line, > I want to print some sql special words, > for example; > 1- if the line start with comment(//) do not print the line. > 2- if line contain "find" and I want to print the leftside of "::" or > class name (like this ClassBase::Class print ClassBase) > 3- if line contain "find" and I want to print the sql commands (like > insert update ...), table and column names. ( like this; insert into > tableA where > columnA, columnB, columnC... print he TableA and ColumnA, columnB, > columnCˇˇ...) > > please help me. what I done so far; 1- i think it OK. 2- It almost done but I can do print it with this code text[/(D.*)+::/], if the line contains second :: it print also. I dontwant it. 3- maybe 50 percent, i can print text.grep( /FROM\s+(.*?)\s+WHERE/ ) do |line| puts line end but it is not what I want. please help me!... -- Posted via http://www.ruby-forum.com/.