为了账号安全,请及时绑定邮箱和手机立即绑定

.NET RegEx 用于替换 URL 中的语言代码

.NET RegEx 用于替换 URL 中的语言代码

C#
素胚勾勒不出你 2021-10-23 17:05:01
如何更改 C# 函数中的以下正则表达式以获得如下所示的结果?我可以修改 RegEx 模式而不是 C# 代码,因为语言代码的总数是固定的吗?谢谢。C# 函数:public static string GetSubdomain(string url){    string pat = @"^https://www\.(.*?)/(english|german|italian)/.*$";    string rep = @"http://$2.$1/";    return Regex.Replace(url, pat, rep);}结果:http://www.example.org/english/  => http://en.example.org/http://www.example.org/german/   => http://de.example.org/http://www.example.org/italian/  => http://it.example.org/
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 132 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号