How to extract HyperLink/s from each cell in a excel Datatable

Hi All,

I need to extract only the link from the each cell in the column from the excel datatable.
Sometimes there could be more than one link in each cell.
I tried using for each and used Matches where in gave the
Input as DatatableName.Columns(ColumnName).ToString
Pattern as “\S*(http|https)\S*” to get only the link.

But I could see that data in the row is not taken and there is a blank output.
Could you please help?

Thank you!

blank output because it’s not matching your pattern

Can we have an example like how we want to extract
@bT_de

give some examples of what you want to extract exactly

Actually I see a mistake in this DatatableName.Columns(ColumnName).ToString.

The o/p is always column name only

you need to pass particular column values row by row??

use row(“YourColumnName”).ToString
pass this as a Input to matches input

Yes this actually give the column name
And if you want to iterate through each value in that column
Pass that datatable to a FOR EACH ROW activity as input and inside the loop use MATCHES activity and in the input property mention as row(“yourcolumnname”).ToString and the Regex expression you have currently
So that will we get the match for those values in each row

Cheers @bT_de

@Palaniyappan & @Pradeep_Shiv

I need to extract the Links from MailBody columns and add it as a new row just below the existing row and then i need to pick the link and do open browser.

some cell has multiple matching strings!
how are you handling those?

@Pradeep_Shiv - Actually this is a sample. There will be mutliple links in each cell but with unique link.

as i can see there are three links in 2nd row from there you want all three or anyone??

@PalaniyappanSeq_GetUnreadMail.xaml (25.2 KB)

@Pradeep_Shiv … Yea in the second row there are three same links.
But In real time there will be multiple links which are different from each other and i need to xtract all of them.

Hi @bT_de,

Here is an activity called “Get Hyperlink” and “Extract HyperLinks” in the below package that it extract the hyper link from excel

Regards
Balamurugan.S

change for each row type of argument string to Object linksList

instead of this FilteredDataTable.Columns(“Mailbody”).ToString
row(“MailBody”).ToString keep this

@Pradeep_Shiv
change for each row type of argument string to Object linksList - Sorry I don’t get this.

you are trying to print regex matched string right??
for that you are using for each loop and the type of argument you are using is String change it to Object

Hi @bT_de,

You can try this

image

  • Regular expresion: (?<URL>http\S+), result is saved into matches variable
  • Take first match: matches.FirstOrDefault, result is saved into match variable
  • Get text from group defined with regex: match.Groups("URL").ToString

I hope this can help you