From: dJD col Date: 2013-07-10T02:44:54+09:00 Subject: search a string with ruby then read what comes after the string in the same line I am trying to look for a a given string in a text and once i find the string I want to be able to store a string that comes after it. For example I would look for a String "JUNE" and once I find "JUNE" in the text I want to store the string that follows JUNE in a variable x. This string should be 7 characters. So if the text has "JUNE seventh 2012". I want to be able to store the string seventh in a variable x. Such that puts x will print seventh on the screen. This is what I have so far but this only prints the string that I am looking for. I would like to be able to print the string that comes after the string I am looking for. file_names = ['Document.txt'] file_names.each do |file_name| text = File.read(file_name) x = text.scan("June") puts x end please advise. -- Posted via http://www.ruby-forum.com/.