Extract Sheet Id

Hii Team,

We need to Extract the Sheet Id from the Link which is present in below format how could we apply the regex

https://docs.google.com/spreadsheets/d/1_pSnkJZ8VLe8XNF-nlTfANobYyDA8jGyf/edit?usp=drive_link&ouid=108668907400524821402&rtpof=true&sd=true

Id to be Extracted: 1_pSnkJZ8VLe8XNF-nlTfANobYyDA8jGyf

Thanks in advance

@anmita

Can try this

System.Text.RegularExpressions.Regex.Match(str,"(?<=/d/).*(?=/edit)").ToString

cheers

@anmita
Try this:

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,“(?<=\/d\/)([\w-]+)”)

Hi @anmita

You can use the regex expression to extract the required output. Please check the below regex expression.

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,“((?<=/\w{1}/).*(?=/))”)

Hope it helps!!

Hi @anmita
Can you try this

I hope it helps!!

Thanks @Anil_G , @raja.arslankhan , @mkankatala and @lrtetala for your prompt solutions!!!

1 Like

@anmita welcome.

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