title: Scala triple quote string and comments
body: <p>When writing Regexes I find the <code>"""</code> syntax of scala very handy because I can write my regexes step by step in a new line</p>
  
  <p>ex:</p>
  
  <pre><code>val foo =
  """
    (
    |(
    |\d{3}
    ||
    |\(\d{3}\)
    |)?
    |(
    |\s|-|\.
    |)?
    |\d{3}
    |(\s|-|\.)
    |\d{4}
    |(
    |\s*
    |(
    |ext|x|extn|extn.
    |)
    |\s*
    |\d{2,6}
    |)?
    |)""".stripMargin.replace("\n", "").r
  </code></pre>
  
  <p>However I wish that I could have written comments to explain what I am doing in each line like</p>
  
  <pre><code>  val foo =
       """(                       // start group to capture the phone number
         |(                       // start of optional area code choices
         |\d{3}                   // bare three digits
         ||                       // or
         |\(\d{3}\)               // three digits enclosed in parentheses
         |)?                      // end of optional area code choices
         |(                       // start of optional separator
         |\s|-|\.                 // start of optional separator
         |)?                      // separator can be whitespace, dash or period
         |\d{3}                   // exchange number (required)
         |(\s|-|\.)               // same separator but required this time
         |\d{4}                   // final digits (required)
         |(                       // start of optional extension
         |\s*                     // zero or more characters of white space
         |(                       // start of extention indicator
         |ext.|x.|ext.|extn.      // extention can be indicated by "ext", "x", or extn followed by any character
         |)                       // end of extension indicator
         |\s*                     // zero or more characters of white space
         |\d{2,6}                 // two to five digits of extension number
         |)?                      //  end of optional estension
         |)""".stripMargin.replace("\n", "").trim
    println(foo)
    val regex = foo.r
    val input = "(888)-456-7890 extn: 12345"
    regex.findAllIn(input).foreach(println)
  </code></pre>
  
  <p>But scala makes the comments a part of the string itself. So how can I write comments and multi line strings like here in <strong>python</strong></p>
  
  <pre><code>verboseRegex = re.compile(r'''
      (             # start group to capture the phone number
      (             #  start of optional area code choices
      \d{3}         #   bare three digits
      |             #   or
      \(\d{3}\)     #   three digits enclosed in parentheses
      )?            #  end of optional area code choices
      (             #  start of optional separator
      \s|-|\.       #   separator can be whitespace, dash or period
      )?            #  end of optional separator
      \d{3}         #  exchange number (required)
      (\s|-|\.)     #  same separator but required this time
      \d{4}         #  final digits (required)
      (             #  start of optional extension
      \s*           #   zero or more characters of white space
      (             #   start of extention indicator
      ext|x|ext.    #    extention can be indicated by "ext", "x", or
                    #      "ext" followed by any character
      )             #   end of extension indicator
      \s*           #   zero or more characters of white space
      \d{2,5}       #   two to five digits of extension number
      )?            #  end of optional estension
      )             # end phone number capture group
      ''', re.VERBOSE)
  </code></pre>
  
  <p>So in the python code above we are using the <code>'''</code> which seems like our scala <code>"""</code> but we are also able to write comments.</p>