# $ anchor for string of a whole file

**URL:** <https://www.ruby-forum.com/t/anchor-for-string-of-a-whole-file/70493>\
**Category:** Ruby\
**Created:** [September 29, 2006, 5:55pm UTC](https://www.ruby-forum.com/t/anchor-for-string-of-a-whole-file/70493 "2006-09-29T17:55:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [September 29, 2006, 5:55pm UTC](https://www.ruby-forum.com/t/anchor-for-string-of-a-whole-file/70493/1 "2006-09-29T17:55:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [September 29, 2006, 6:17pm UTC](https://www.ruby-forum.com/t/anchor-for-string-of-a-whole-file/70493/2 "2006-09-29T18:17:23Z")

</div>

Peter B. wrote:

> 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.\*$”
