# Re: $ anchor for string of a whole file

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

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [September 29, 2006, 6:05pm UTC](https://www.ruby-forum.com/t/re-anchor-for-string-of-a-whole-file/70496/1 "2006-09-29T18:05:08Z")

</div>

> And, shouldn’t /m tell it to include everying, including newlines?

No, the multiline option causes the regexp engine to include newlines in  
the ‘.’ character class. Unlike some other languages, I don’t believe it  
has any effect on ^ or $.

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [September 29, 2006, 6:51pm UTC](https://www.ruby-forum.com/t/re-anchor-for-string-of-a-whole-file/70496/2 "2006-09-29T18:51:15Z")

</div>

On 2006.09.30 01:03, Gavin K. wrote:

> > And, shouldn’t /m tell it to include everying, including newlines?
> 
> No, the multiline option causes the regexp engine to include newlines in  
> the ‘.’ character class. Unlike some other languages, I don’t believe it  
> has any effect on ^ or $.

That is correct–^matches right after a newline and $ right before  
it. \A and \Z are beginning and end of a given String, respectively.
