Split Ruby regex over multiple lines

Using %r with the x option is the prefered way to do this.

See this example from the github ruby style guide

regexp = %r{
  start         # some text
  \s            # white space char
  (group)       # first group
  (?:alt1|alt2) # some alternation
  end
}x

regexp.match? "start groupalt2end"

https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md#regular-expressions

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)