Skip to content

Commit dc03d8c

Browse files
Merge pull request #4934 from gitfoxi/master
Multi-line regular expressions.
2 parents db2c6ef + 95b0894 commit dc03d8c

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

base/exports.jl

+1
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,7 @@ export
12371237
@__FILE__,
12381238
@b_str,
12391239
@r_str,
1240+
@r_mstr,
12401241
@v_str,
12411242
@mstr,
12421243
@unexpected,

base/regex.jl

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ end
3434
Regex(pattern::String) = Regex(pattern, DEFAULT_OPTS)
3535

3636
macro r_str(pattern, flags...) Regex(pattern, flags...) end
37+
macro r_mstr(pattern, flags...) Regex(pattern, flags...) end
3738

3839
copy(r::Regex) = r
3940

doc/manual/strings.rst

+21
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,27 @@ For example, the following regex has all three flags turned on:
699699
julia> match(r"a+.*b+.*?d$"ism, "Goodbye,\nOh, angry,\nBad world\n")
700700
RegexMatch("angry,\nBad world")
701701

702+
Sometimes you want use double-quotes in regular expressions. Escaping them can
703+
be annoying. Now you can use tripple quotes.
704+
705+
.. doctest::
706+
707+
julia> r = r"""
708+
"[^"]*"
709+
"""xs
710+
r"
711+
\"[^\"]*\"
712+
"sx
713+
714+
Triple-quoted strings have worked for a while now:
715+
716+
.. doctest::
717+
718+
julia> match(r, """
719+
"foo"
720+
""")
721+
RegexMatch("\"foo\"")
722+
702723
Byte Array Literals
703724
~~~~~~~~~~~~~~~~~~~
704725

0 commit comments

Comments
 (0)