# Regex doesn't match end of line with both carriage return and line feed

**URL:** <https://discourse.julialang.org/t/regex-doesnt-match-end-of-line-with-both-carriage-return-and-line-feed/5795>\
**Category:** General Usage\
**Created:** [September 8, 2017, 11:16pm UTC](https://discourse.julialang.org/t/regex-doesnt-match-end-of-line-with-both-carriage-return-and-line-feed/5795 "2017-09-08T23:16:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [September 8, 2017, 11:16pm UTC](https://discourse.julialang.org/t/regex-doesnt-match-end-of-line-with-both-carriage-return-and-line-feed/5795/1 "2017-09-08T23:16:26Z")

</div>

I was trying to use the `Regex` feature where `^` and `$` match the start and end of individual lines instead of the whole string, and I noticed that:

```julia
$ match(r"does$"m, "this does\r\nnot work")

$ match(r"does$"m, "this does\nwork")
RegexMatch("does")

```

Is this as expected, or is this a bug?

---

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [September 9, 2017, 3:27am UTC](https://discourse.julialang.org/t/regex-doesnt-match-end-of-line-with-both-carriage-return-and-line-feed/5795/2 "2017-09-09T03:27:09Z")

</div>

This behavior depends on how the underlying regexp library was compiled. You can do this to override the default behavior:

```julia
julia> match(r"(*ANYCRLF)does$"m, "this does\r\nso work")
RegexMatch("does")

```

(See [the Wikipedia article on PCRE](https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions) for details, especially alternative versions of the EOL spec.)

---

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [September 9, 2017, 4:03pm UTC](https://discourse.julialang.org/t/regex-doesnt-match-end-of-line-with-both-carriage-return-and-line-feed/5795/3 "2017-09-09T16:03:17Z")

</div>

Great explanation, thank you!
