@Th11
I am suggesting .net script based solution for your use case.
My flow screenshot:

PAD action Explanation:
Variables.CreateNewDatatable InputTable:
- Create a new DataTable named DataTable with column names Firstname, DOB, and Message Text. Initialize it with an empty row.
Scripting.RunDotNetScript:
- mention the System.Text.RegularExpressions namespace.
- Define a C# script that performs the actions required action: reading the text file, defining the regular expression pattern, matching the pattern against the text, removing the first row from the DataTable, and adding extracted data to the DataTable.
- The script receives filename and dataTable as inputs and updates the dataTable with extracted data.
- The input and output parameters are specified in the configuration of the action.
Code[Change the input file parameter alone]:
Variables.CreateNewDatatable InputTable: { ^['Firstname', 'DOB', 'Message Text'], [$'''''', $'''''', $''''''] } DataTable=> DataTable
Scripting.RunDotNetScript Imports: $'''System.Text.RegularExpressions''' Language: System.DotNetActionLanguageType.CSharp Script: $'''// Read the text file
string text = File.ReadAllText(filename);
// Define the regular expression pattern
string pattern = @\"Firstname: (?<firstname>\\w+)\\s+DOB: (?<dob>\\d{2}/\\d{2}/\\d{2})\\r?\\nLastname: \\w+\\s+Fileno: \\d+\\r?\\nMessage Text: (?<message>.+?)\\s+\";
// Match the pattern against the text
MatchCollection matches = Regex.Matches(text, pattern);
// Remove the first row from the DataTable
if (dataTable.Rows.Count > 0)
{
dataTable.Rows.RemoveAt(0);
}
// Extract the required information and add to DataTable
foreach (Match match in matches)
{
string firstname = match.Groups[\"firstname\"].Value;
string dobString = match.Groups[\"dob\"].Value;
string message = match.Groups[\"message\"].Value;
// Add the extracted data to the DataTable
dataTable.Rows.Add(firstname, dobString, message);
}''' @'name:dataTable': DataTable @'type:dataTable': $'''Datatable''' @'direction:dataTable': $'''InOut''' @'name:filename': $'''C:\\\\Users\\\\deenu\\\\OneDrive\\\\Desktop\\\\data.txt''' @'type:filename': $'''String''' @'direction:filename': $'''In''' @dataTable=> DataTable
New to PAD, Not sure how to copy/paste above code?

Please let me know in case if you have any queries.
Thanks,
Deenuji Loganathan 👩💻
Automation Evangelist 🤖
Follow me on LinkedIn 👥
-------------------------------------------------------------------------------------------------------------
If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀. If you'd like to appreciate me, please write a LinkedIn recommendation 🙏