$ anchor for string of a whole file

P

Peter Bailey

I can't seem to get the regex I want when I'm searching for something at
the end of a file. I express it with relevant characters, followed by a
$. Because I've read in an entire file as one string into memory,
shouldn't $ mean the end of the file? And, shouldn't /m tell it to
include everying, including newlines?

file_contents = File.read(psfile)
file_contents.scan(/(\%\%Blank page for Asura$)/m) do
file_contents.delete($1)
end

Thanks,
Peter
 
P

Peter Bailey

Peter said:
I can't seem to get the regex I want when I'm searching for something at
the end of a file. I express it with relevant characters, followed by a
$. Because I've read in an entire file as one string into memory,
shouldn't $ mean the end of the file? And, shouldn't /m tell it to
include everying, including newlines?

file_contents = File.read(psfile)
file_contents.scan(/(\%\%Blank page for Asura.*$)/m) do
file_contents.delete($1)
end

Thanks,
Peter

I had to correct "Asura$" to "Asura.*$"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top