gpt4 book ai didi

c# - 本场比赛的正则表达式

转载 作者:太空宇宙 更新时间:2023-11-03 11:00:17 24 4
gpt4 key购买 nike

所以我有示例 url http://citrine.rcd.dev:8080/image/1582_125x125.jpg

它是用代码构建的:

    public string GetDerivativeUrl(long imageId, bool preserveTransparency, DerivativeSize size, bool allowCache, string designTags, int quality)
{
string tags = (designTags == null || designTags.Trim().Length == 0) ? "" : designTags;
string imageFormat = (preserveTransparency) ? "png" : "jpg";
if (quality > 0)
return String.Format("{0}/image/{4}{1}_{2}.{3}?qv={5}", GetUrlPrefix(imageId, allowCache), imageId, size.GetPixelSize(), imageFormat, tags, quality);
return String.Format("{0}/image/{4}{1}_{2}.{3}", GetUrlPrefix(imageId, allowCache), imageId, size.GetPixelSize(), imageFormat, tags);
}

我想从http://citrine.rcd.dev:8080/image/1582_125x125获取http://citrine.rcd.dev:8080/image/1582.jpg .jpg

我该怎么做?

最佳答案

使用System.Uri从路径中获取文件名部分,然后将 "_.*?\." 替换为 "."

关于c# - 本场比赛的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17923167/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com