Stream: helpdesk (published)

Topic: Regex matching with \r\n


view this post on Zulip Fredrik Ekre (Jul 04 2021 at 19:32):

Is there a way to make ^ and $ also match \r\n style line endings?

julia> str = "foo\r\nbar\r\n\baz";

julia> str2 = replace(str, "\r\n" => "\n");

julia> m = match(r"^bar$"m, str)

julia> m = match(r"^bar$"m, str2)
RegexMatch("bar")

view this post on Zulip Sascha Mann (Jul 04 2021 at 19:54):

julia> match(r"(*ANYCRLF)^bar$"m, str)
RegexMatch("bar")

view this post on Zulip Sebastian Pfitzner (Jul 04 2021 at 19:56):

TIL

view this post on Zulip Fredrik Ekre (Jul 04 2021 at 19:59):

Thanks!

view this post on Zulip Felix Kastner (Jul 04 2021 at 20:09):

Reference: http://www.pcre.org/current/doc/html/pcre2syntax.html#SEC17


Last updated: Dec 28 2024 at 04:38 UTC