正则表达式修改Google云端硬盘共享文件网址

我正在尝试创建一个脚本,将常规的Google云端硬盘共享网址转换为直接下载网址.原始URL如下所示:
https://drive.google.com/file/d/FILE_ID/edit?usp=sharing

并需要转换为如下所示:

https://drive.google.com/uc?export=download&id=FILE_ID

因此,我正在尝试使用我不熟悉的正则表达式来获取删除/更改的所需文本.我正在使用RegExr尝试创建它,但我只能得到它

/file/d/

我尝试过一种消极的前瞻,但它似乎没有用.有什么建议?

2017年3月23日更新

对于PHP

$link = preg_replace('%https://drive\.google\.com/file/d/(.*?)/.*?\?usp=sharing%','https://drive.google.com/uc?export=download&id=$1',$link);

对于Python:

result = re.sub(r"https://drive\.google\.com/file/d/(.*?)/.*?\?usp=sharing",r"https://drive.google.com/uc?export=download&id=\1",url)

对于Perl:

$subject =~ s!https://drive\.google\.com/file/d/(.*?)/.*?\?usp=sharing!https://drive.google.com/uc?export=download&id=$1!g;

对于Java:

String resultString = subjectString.replaceAll("https://drive\\.google\\.com/file/d/(.*?)/.*?\\?usp=sharing","https://drive.google.com/uc?export=download&id=$1");

对于Ruby:

result = subject.gsub(/https:\/\/drive\.google\.com\/file\/d\/(.*?)\/.*?\?usp=sharing/,'https://drive.google.com/uc?export=download&id=\1')

对于C#:

resultString = Regex.Replace(subjectString,@"https://drive\.google\.com/file/d/(.*?)/.*?\?usp=sharing","https://drive.google.com/uc?export=download&id=$1");

对于R语言:

~gsub("https://drive\\.google\\.com/file/d/(.*?)/.*?\\?usp=sharing","https://drive.google.com/uc?export=download&id=\\1",subject,perl=TRUE);

对于Javascript:

result = subject.replace(/https:\/\/drive\.google\.com\/file\/d\/(.*?)\/.*?\?usp=sharing/g,"https://drive.google.com/uc?export=download&id=$1");

对于TCL:

regsub -linestop -all {https://drive\.google\.com/file/d/(.*?)/.*?\?usp=sharing} $subject "https://drive.google.com/uc?export=download\\&id=\\1" result

对于Oracle:

result := REGEXP_REPLACE(subject,'https://drive\.google\.com/file/d/(.*)/.*?\?usp=sharing','https://drive.google.com/uc?export=download&id=\1',1,'c');

对于C:

wxString ;
wxRegEx regexObj(_T("(?p)\\Ahttps://drive\\.google\\.com/file/d/(.*?)/.*?\\?usp=sharing"),wxRE_ADVANCED);
regexObj.ReplaceAll(&subjectString,_T("https://drive.google.com/uc?export=download\\&id=\\1"));

对于Groovy:

Matcher regexMatcher = subjectString =~ /https:\/\/drive\.google\.com\/file\/d\/(.*?)\/.*?\?usp=sharing/
String resultString = regexMatcher.replaceAll('https://drive.google.com/uc?export=download&id=$1');

对于Postgresql

SELECT REGEXP_REPLACE(mycolumn,$$(?p)https://drive\.google\.com/file/d/(.*?)/.*?\?usp=sharing$$,$$https://drive.google.com/uc?export=download&id=\1$$,'g') FROM mytable;

对于VisualBasic.NET:

Dim RegexObj As New Regex("https://drive\.google\.com/file/d/(.*?)/.*?\?usp=sharing")
ResultString = RegexObj.Replace(SubjectString,"https://drive.google.com/uc?export=download&id=$1")

对于Delphi XE:

Dim RegexObj As New Regex("https://drive\.google\.com/file/d/(.*?)/.*?\?usp=sharing")
ResultString = RegexObj.Replace(SubjectString,"https://drive.google.com/uc?export=download&id=$1")

对于PowerShell:

$regex = [regex] 'https://drive\.google\.com/file/d/(.*?)/.*?\?usp=sharing'
$result = $regex.Replace($subject,'https://drive.google.com/uc?export=download&id=$1')

对于Xpath:

fn:replace($input,"https://drive\.google\.com/file/d/(.*?)/.*?\?usp=sharing","https://drive.google.com/uc?export=download&id=$1")

对于VBscript:

Dim myRegExp,ResultString
Set myRegExp = New RegExp
myRegExp.Global = True
myRegExp.Pattern = "https://drive\.google\.com/file/d/(.*?)/.*?\?usp=sharing"
ResultString = myRegExp.Replace(SubjectString,"https://drive.google.com/uc?export=download&id=$1")

如果您需要其他语言,请告诉我!

相关文章

正则替换html代码中img标签的src值在开发富文本信息在移动端...
正则表达式
AWK是一种处理文本文件的语言,是一个强大的文件分析工具。它...
正则表达式是特殊的字符序列,利用事先定义好的特定字符以及...
Python界一名小学生,热心分享编程学习。
收集整理每周优质开发者内容,包括、、等方面。每周五定期发...