title: scala regex : extract from string
body: <p>I am trying to extract few values out of an big string , I have an hard time extracting them , I have tired a couple of regex patterns , but they always give me no match. Anyway they seem to work in the online regex sites available but not in Scala. What I am trying to do is</p>
  
  <p><strong>Input :</strong> </p>
  
  <p>ESSSTOR\Disk&amp;Ven_VendorName&amp;Prod_MO_Might_MS_5.0&amp;Rev_6.01\08765J54U3K4QVR0&amp;0</p>
  
  <p><strong>Extract [output]:</strong></p>
  
  <p>Vendorname</p>
  
  <p>MO_Might_MS_5.0&amp;Rev_6.01</p>
  
  <p>08765J54U3K4QVR0&amp;0</p>
  
  <p>I am trying to extract those three values from the input string , but unable to do so.</p>
  
  <p>Can some one please me see what I am doing wrong.</p>
  
  <p>Thanks in advance.</p>
  
  <p>//Input value</p>
  
  <pre><code>  val device:String=  "ESSSTOR\\Disk&amp;Ven_VendorName&amp;Prod_MO_Might_MS_5.0&amp;Rev_6.01\\08765J54U3K4QVR0&amp;0"
  </code></pre>
  
  <p>// Regex build for product extraction</p>
  
  <pre><code>           val proReg=  """.*[Prod_]([^\\\\]*)""".r
                       // """.*Prod_([^\\\\]*)""".r  -- no match as output
                      // """(?:Prod_)([^\\\\]*)""".r  -- no match as output
  
        println("Device: "+device)
  
      // method -1:   
      device match{
  
        case proReg(prVal) =&gt; println(s"$prVal is product val")
        case _ =&gt;  println("no match")   }
  
      // method-2 : 
  
     val proReg(g1) = "ESSSTOR\\Disk&amp;Ven_VendorName&amp;Prod_MO_Might_MS_5.0&amp;Rev_6.01\\08765J54U3K4QVR0&amp;0"
     println(s"group1: $g1 ")
  
  
     O/P:
  
  
    Device:  ESSSTOR\Disk&amp;Ven_VendorName&amp;Prod_MO_Might_MS_5.0&amp;Rev_6.01\08765J54U3K4QVR0&amp;0
  
     //method-1
  
     no match
  
     // method-2
  
     error
  </code></pre>
  
  <p>// Regex build for dev serial</p>
  
  <pre><code>    val serReg = """(?:Prod_\\S*[\\\\])(.*)""".r
  
      device match {
        case serReg(srVal) =&gt; println(s"$srVal is product val")
        case _ =&gt; println("no match")
      }
  
  
      o/p:
  
      no match
  </code></pre>
  
  <p>// Regex for vendor</p>
  
  <pre><code>    val venReg="""(?:Ven_)([^&amp;]*)""".r
  
      device match {
        case venReg(vnVal) =&gt; println(s"$vnVal is vendor val")
        case _ =&gt; println("no match")
      }
  
  
      o/p:
  
      no match
  </code></pre>