fork download
  1. Imports System
  2. Imports System.Collections.Generic
  3. Imports System.Text.RegularExpressions
  4.  
  5. Public Class Test
  6. Public Shared Sub Main()
  7. Dim values As String = "output1: unshared" & Chr(10) & "owner: unknown" & Chr(10) & "public: EU" & Chr(10) & "scope: this" & Chr(10) & "value type: string" & Chr(10) & "enum values: ""----- / ASIL C"", ""SIL 0 / QM"", ""SIL 1 / ASIL A"", ""SIL 2 / ASIL B"", ""SIL 3 / ASIL D"""
  8.  
  9. Dim pattern As String = "(?<=enum values:.*?"")[^""]*(?=""(?![^,]))" 'finding the right data line
  10. Dim matches As MatchCollection = Regex.Matches(values, pattern) ' REPLACED Match WITH Matches
  11. Dim retVal As New List(Of String)
  12.  
  13. For Each match As Match In matches
  14. retVal.Add(Regex.Replace(match.Value, "[^A-Za-z0-9]+", ""))
  15. Next
  16.  
  17. ' Just to print
  18. For Each s As String In retVal
  19. Console.WriteLine(s)
  20. Next
  21. End Sub
  22. End Class
Success #stdin #stdout 0.07s 25592KB
stdin
1
2
10
42
11
stdout
ASILC
SIL0QM
SIL1ASILA
SIL2ASILB
SIL3ASILD