title: Regex and VB.net pattern matching
body: <p>I am writing a VB.net program to detect a words. Here is my sample text file:</p>
  
  <pre><code>EXTERNAL 16EVP_PK   -- FL(4) TDC PERMIT CONTRL TO MESTO CONTRL  
                      -- FL(5) $HY04B09.BOXTSTAT (= RUN = ON)   
  EXTERNAL 16EVPUPK   -- FL(33) REQUEST FROM METSO FOR CONTRL   
  EXTERNAL 16SA0541                                 -- SP VALUES TRANSFERS  
  EXTERNAL 16FC0730, 16FC0815, 16FC0830   -- Hiway 4 Tags   
  EXTERNAL 16FC1525                       -- Hiway 4 Tags
  </code></pre>
  
  <p>I want to detect everything <strong>after EXTERNAL and before --</strong> (EXTERNAL can be external or ExTernal or any combination) . The first match should read "16EVP_PK" second match 16EVPUPK third match 16SA0541 fourth match "16FC0730, 16FC0815, 16FC0830" and so on</p>
  
  <p>Here is the code that I have written:</p>
  
  <pre><code>Private Sub CheckCLFile()
  path="D:\16METEVP.CL"
  'Read CL file
  Dim value As String = System.IO.File.ReadAllText(path)
  Dim Pattern As String = "(?m)(?&lt;=\bExternal).*$"
  Debug.WriteLine(value)
  Debug.WriteLine(Regex.Matches(value, Pattern).Count())
  For Each m As Match In Regex.Matches(value, Pattern)
  Console.WriteLine("'{0}' found at index {1}.",
                            m.Value, m.Index)
  Next
  End Sub
  </code></pre>
  
  <p>Thanks in advance.</p>