Multiline regex layout

Viewed 587

I have a regex: Regex("((group1)(group2))(group3)")

I'd like to format it in a way that looks nice and clear, i.e.:

(
  (group1)
  (group2)
)
(group3)

For example I've tried this:

Regex("("
    +   "(group1)"
    +   "(group2)"
    + ")"
    + "(group3)")     //--> loses the syntax highlighting in Intellij and a bit messy

Regex("""(
           (group1)
           (group2)
         )
         (group3)""") //--> not bad, but not equivalent (adds spaces and \n characters)

Is there a way to have a clean layout while keeping the regex equivalent to the original and the syntax highlighting?

1 Answers
Related