Regex to modify Google Drive shared file URL

后端 未结 4 817
萌比男神i
萌比男神i 2021-02-04 16:37

I\'m trying to create a script to convert a regular google drive share URL to a direct download URL. The raw URL looks like this:

https://drive.google.com/file/d         


        
4条回答
  •  [愿得一人]
    2021-02-04 17:03

    This works in PCRE, in regex101:

    • Find what: ^(https:\/\/drive\.google\.com\/)file\/d\/([^\/]+)\/.*$
    • Replace with: $1uc?export=download&id=$2
    • Try it: http://regex101.com/r/dX1zD2

    Please consider bookmarking the Stack Overflow Regular Expressions FAQ for future reference.

提交回复
热议问题