I am writing a VB.net program to detect a words. Here is my sample text file:
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
I want to detect everything after EXTERNAL and before -- (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
Here is the code that I have written:
Private Sub CheckCLFile()
path="D:\16METEVP.CL"
'Read CL file
Dim value As String = System.IO.File.ReadAllText(path)
Dim Pattern As String = "(?m)(?<=\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
Thanks in advance.