# Multiline Regex

**URL:** <https://discourse.julialang.org/t/multiline-regex/25477>\
**Category:** General Usage\
**Tags:** strings, regex\
**Created:** [June 20, 2019, 9:36am UTC](https://discourse.julialang.org/t/multiline-regex/25477 "2019-06-20T09:36:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amval](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amval/32/6217_2.png) [@Amval](https://discourse.julialang.org/u/Amval)\
**Post date:** [June 20, 2019, 9:36am UTC](https://discourse.julialang.org/t/multiline-regex/25477/1 "2019-06-20T09:36:26Z")

</div>

Hello all,

I am trying to split a long regex into different lines. I am aware that string macros can be called with triple quotes. However this introduces a newline at the end. Any way of avoiding this?

---

<div class="post-metadata">

**Author:** ![c42f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c42f/32/52842_2.png) [@c42f](https://discourse.julialang.org/u/c42f)\
**Post date:** [June 20, 2019, 9:53am UTC](https://discourse.julialang.org/t/multiline-regex/25477/2 "2019-06-20T09:53:40Z")

</div>

Perhaps you’d like regex “comment mode” where non-significant whitespace and comments are allowed within the regex string. This is enabled with the `x` suffix to the `r` string macro:

```julia
julia> match(r"(aa| # a comment
                bb|
                cc)"x, "bb")
RegexMatch("bb", 1="bb")

```

---

<div class="post-metadata">

**Author:** ![Amval](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amval/32/6217_2.png) [@Amval](https://discourse.julialang.org/u/Amval)\
**Post date:** [June 22, 2019, 3:25pm UTC](https://discourse.julialang.org/t/multiline-regex/25477/3 "2019-06-22T15:25:40Z")

</div>

Yes, this solves exactly the issue (also for the triple quotes). Thank you!
