i'm trying to get a group of text in between 2 strings in ruby, and i can't seem to get the right method or use the right regex.
text:
<html>
<body>
<!-- begin posts -->
<h1>all kinds of html<h1>
<p> blah blah </p>
<p> i've been working on this forever </p>
<!-- end posts -->
</html>
</body>
and i just want to get everything from <!-- begin posts -->
to <!-- end posts -->
, inclusive, and save that block of text in a text file.
i figured out how to print the line in the beginning:
File.open("index.html").each_line do |line|
body.each {|line| puts line if line =~ /<!-- begin/}
but not the lines after up and until the last string.
i have a rubular here http://rubular.com/r/0W9QDpMGkM where i haven't been able to figure out anything.
thanks everyone in advance.