From 5f73b84d845211bc8f6874c048b7837e85fcdb7c Mon Sep 17 00:00:00 2001 From: Michael Fox Date: Mon, 25 Nov 2013 23:06:30 -0800 Subject: [PATCH 1/2] Multi-line regex string --- base/exports.jl | 1 + base/regex.jl | 1 + 2 files changed, 2 insertions(+) diff --git a/base/exports.jl b/base/exports.jl index 2e15a25b01539..e4be7095a3347 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -1237,6 +1237,7 @@ export @__FILE__, @b_str, @r_str, + @r_mstr, @v_str, @mstr, @unexpected, diff --git a/base/regex.jl b/base/regex.jl index 30a3b834dc829..1d5e649c521de 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -34,6 +34,7 @@ end Regex(pattern::String) = Regex(pattern, DEFAULT_OPTS) macro r_str(pattern, flags...) Regex(pattern, flags...) end +macro r_mstr(pattern, flags...) Regex(pattern, flags...) end copy(r::Regex) = r From 95b0894ac5af5011b0ac58b38091b4d2cc4be9ae Mon Sep 17 00:00:00 2001 From: Michael Fox Date: Mon, 25 Nov 2013 23:13:28 -0800 Subject: [PATCH 2/2] Document triple-quoted strings and tripple-quoted regex --- doc/manual/strings.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/manual/strings.rst b/doc/manual/strings.rst index 0627d4e7c3f20..13f8d656b881c 100644 --- a/doc/manual/strings.rst +++ b/doc/manual/strings.rst @@ -699,6 +699,27 @@ For example, the following regex has all three flags turned on: julia> match(r"a+.*b+.*?d$"ism, "Goodbye,\nOh, angry,\nBad world\n") RegexMatch("angry,\nBad world") +Sometimes you want use double-quotes in regular expressions. Escaping them can +be annoying. Now you can use tripple quotes. + +.. doctest:: + + julia> r = r""" + "[^"]*" + """xs + r" + \"[^\"]*\" + "sx + +Triple-quoted strings have worked for a while now: + +.. doctest:: + + julia> match(r, """ + "foo" + """) + RegexMatch("\"foo\"") + Byte Array Literals ~~~~~~~~~~~~~~~~~~~