title: Scala: Matching optional Regular Expression groups
body: <p>I'm trying to match on an option group in Scala 2.8 (beta 1) with the following code:</p>
  
  <pre><code>import scala.xml._
  
  val StatementPattern = """([\w\.]+)\s*:\s*([+-])?(\d+)""".r
  
  def buildProperty(input: String): Node = input match {
      case StatementPattern(name, value) =&gt; &lt;propertyWithoutSign /&gt;
      case StatementPattern(name, sign, value) =&gt; &lt;propertyWithSign /&gt;
  }
  
  val withSign = "property.name: +10"
  val withoutSign = "property.name: 10"
  
  buildProperty(withSign)        // &lt;propertyWithSign&gt;&lt;/propertyWithSign&gt;
  buildProperty(withoutSign)     // &lt;propertyWithSign&gt;&lt;/propertyWithSign&gt;
  </code></pre>
  
  <p>But this is not working. What is the correct way to match optional regex groups?</p>