0

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  
0

1 Answer 1

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

Try this to match the whole line.

Edit:

(?:^|\s+)\d{1,6}[)]\s.*$
Sign up to request clarification or add additional context in comments.

1 Comment

again.. I encounter some problem. Can I use OR here? on RegEx pattern? if the start of the string has space or no space? see my updated String extracted from text file(with formatting and spaces) above, I add new text lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.