I need to extract data only file name from entire data

Hi

Input:

1)FW 88.5 Default OFS to update 4.xlsx
Yesterday by Lalitha
2)FW 50.3 Default OFS to update.xlsx
Today by Suresh
3)FW 6.5 Default OFS to update 37.xlsx
3 days ago by Sriram

from above sample input need only filename.

Output:
FW 6.5 Default OFS to update 37.xlsx

Above is the output

Thanks
Likitha

Hi @vinjam_likitha

Please try this

System.Text.RegularExpressions.Regex.Matches(str,"(?<=\d\)).*")

This should be given in assign

Output type is matchcollection(create a variable of this type and use the variable on left side of assign)

Use a for loop with in as matchcollection variable and type argument(you will find in properties panel of for loop) as match and inside the for loop you will get the result as currentitem.value

This will give all 3 file names

Cheers

Hi,

Those input i get from datatable using “for each row in data table” i will read each file we need to use regular expression for each input file

Thanks
Likitha

Can you try this inside for each row,

getFileName = System.Text.RegularExpressions.Regex.Match(str1,“(?<=\d)).*”).ToString
Thank!

Hi @vinjam_likitha

Inside the For each row in Data Table activity use if activity

System.Text.RegularExpressions.Regex.Match(Currentrow("ColumnName").Tostring.Trim,"(?<=\d\)).*").Tostring.Contains("FW 6.5 Default OFS to update 37.xlsx")

In then You can processed with the flow.

Regards
Gokul

@Anil_G for each file as input do i need to use same regular expression?

when i used it i am getting output:
System.Text.RegularExpressions.MatchCollection

You can try with System.Text.RegularExpressions.Regex.Match in the expression @vinjam_likitha

Hi @vinjam_likitha

This is how you use it.Check the xaml. You need to loop to get all results

BlankProcess5 - Copy (6).zip (3.6 KB)

If you are doing it in datatble for each then

use this directly in your for each data row

System.Text.RegularExpressions.Regex.Match(Currentrow("Column Name").Tostring.Trim,"(?<=\d\)).*").Tostring

I hope your datatable contains 1) ,2) and 3) in the values

cheers

if u r getting ur input one by one, you can use var.split(".'c)(0)

if i use this then output is balnk

i am not using “for each” for regex

thanks

1 Like

Hi @vinjam_likitha

That is the reason I gave the second part as well

System.Text.RegularExpressions.Regex.Match(Currentrow("Column Name").Tostring.Trim,"(?<=\d\)).*").Tostring

Can you confirm if you will have 1) ,2) and 3) as well in the excel data?

If not can you exactly give how the data would be

cheers

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