Help with finding pattern in a String

I have have a text file containing several rows of data. For each row in the text file:

I want to search for the strings “D6040” and “F”. if a row has the two strings(“D6040” and “F”), I want to write that row to a file.

The output text file should be only rows where both “D6040” and “F” are found.

My attached workflow is using some regex which obviously is not working as expected. Help will be appreciated.

findASerchWordInATextFileAndReturnHitRows.zip (3.9 KB)

HI,

Can you try the following?

Regex pattern : .*\bD6040\b.*\bF\b.*

string.join(vbCrLf,matchesFound.Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) m.Value.TrimEnd))

FYI, we can achieve it using Split and String.Contains method as the following.

String.Join(vbcrlf,contentOfSuperClass.Split(vbcrlf.ToCharArray,StringSplitOptions.RemoveEmptyEntries).Where(Function(s) s.Contains("D6040") AndAlso s.Contains("F")))

Sample (See Main.xaml and Sequence.xaml)
findASerchWordInATextFileAndReturnHitRowsV2.zip (5.0 KB)

Regards,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.