Waelhi
Waelhi

Reputation: 315

If string contains REGEX match

I have TEXT File and extracted every line of data from text file. The extracted data is stored to list of string then I iterate loop to List of string to manipulate and validate the data extracted. Now every line of string I extracted, I want to validate if that line of string is contain 1). I used RegEx for this but it gives me no luck. (Please see image below)

My Text File

enter image description here

Code

Dim strRegexPattern As String = "^\d{1,6}[)]\s$"
Dim myRegex As New Regex(strRegexPattern, RegexOptions.None)
Dim _strMatch As Match = myRegex.Match(line) '<-- i use for each line as string in listOfExtractedLines

    If _strMatch.Success Then
         MsgBox(_strMatch.Value)
    End If

String extracted from text file(with formatting and spaces)

                    Title        : 8015B DRO(C10-C28) - ORO (C18-C36)

          Column01                   Col2 Col3  Column04  Col5 Col06 Col(007)
   --------------------------------------------------------------------------
   Intxxxxx xxxxxxxxx
     1) zzzzzzzzzzzzzzzzzz          4.464  168   212614    25.00 xyz      0.00
    33) aaaaaaaaaaaaaaaaaaa         4.818  114   330529    25.00 xyz      0.00
    51) bbbbbbbbbbbbbbbb            6.742  117   318044    25.00 xyz      0.00
    64) cccccccccccccccccccccc      8.397  152   186712    25.00 xyz      0.00
21)     Endosulfan Sulfa            12.51  13    918.2E6   840.8E6        106.315  
22)     Endrin Ketone               13.11  14    143.4E6   992.2E6        104.978  

Upvotes: 0

Views: 2639

Answers (1)

vks
vks

Reputation: 67998

^.*?\s\d{1,6}[)]\s.*$

Try this to match the whole line.

Edit:

(?:^|\s+)\d{1,6}[)]\s.*$

Upvotes: 1

Related Questions