I need to add a string to a regular expression in ruby, this is what Im trying to do (Im getting all the files in my directory, opening them, finding if they have a pattern, then modifying that pattern by adding to what already exists, to do this I need the actual string)
Dir["*"].each do |tFile|
file = File.open(tFile, "rb")
contents = file.read
imageLine=/<img class="myclass"(.*)\/>/
if(contents=~imageLine)
puts contents.sub!(imageLine, "some string"+imageLine+"some other string")
end
end
File.open(tFile, 'rw')and iterate each line of the file, replacing the line where you find the pattern.putsis going to STDOUT.