-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-line regular expressions. #4934
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1237,6 +1237,7 @@ export | |
@__FILE__, | ||
@b_str, | ||
@r_str, | ||
@r_mstr, | ||
@v_str, | ||
@mstr, | ||
@unexpected, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this example is needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. My goals are:
Anyway, I will rollback and write something better. On Tue, Nov 26, 2013 at 7:54 AM, Steven G. Johnson <[email protected]
Michael There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, no. I'm going to merge this and we can edit after it gets merged. Bikeshedding code is one thing, but bikeshedding documentation is silly. We can just merge and edit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before I get to that, though -- it seem like some of this falls under It seems me that in Julia, the style is to write almost no inline The Julia advantage is that the documentation ends up reading like a The Python advantage is that it's more fun to read source code. I don't know if this is an intentional design decision or just the way On Tue, Nov 26, 2013 at 9:05 AM, Michael Fox [email protected] wrote:
Michael There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
.. doctest:: | ||
|
||
julia> match(r, """ | ||
"foo" | ||
""") | ||
RegexMatch("\"foo\"") | ||
|
||
Byte Array Literals | ||
~~~~~~~~~~~~~~~~~~~ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would shorten this to something like: "You can also use triple-quoted string literals for regular expression, which is convenient for embedding quotation marks and newlines" and then maybe give a single example.