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 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 ~~~~~~~~~~~~~~~~~~~