如何更改 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 回答
- 0 關注
- 143 瀏覽
添加回答
舉報
0/150
提交
取消