Home > Software design >  How to extract a portion of this URL in Google Sheets?
How to extract a portion of this URL in Google Sheets?

Time:11-16

Given this URL: https://drive.google.com/file/d/1pnEX1OQXXXHzu6z9dPV5ZZ5VHqPU--6/view?usp=share_link, how can I extract only what is between d/ and /view?

I've tried it using: =MID(A2,SEARCH("d/",A2) 1,SEARCH("/view",A2)-SEARCH("/view",A2)-1) 0, but it doesn't work.

Here is a practical example, should you feel like killing it

CodePudding user response:

You can use Regular Expressions in Google Sheets. The formula

=REGEXEXTRACT("link text here", "d/(. )/view")

will make the cell value whatever is inside the matching group (whatever is in between "d/" and "/view".

Here is the documentation for Google Sheet's RegEx commands: https://support.google.com/docs/answer/3098244'

You can learn more about Regular Expressions by playtesting with it here: https://regexr.com/

  • Related