如何更改 C# 函數(shù)中的以下正則表達(dá)式以獲得如下所示的結(jié)果?我可以修改 RegEx 模式而不是 C# 代碼,因為語言代碼的總數(shù)是固定的嗎?謝謝。C# 函數(shù):public static string GetSubdomain(string url){ string pat = @"^https://www\.(.*?)/(english|german|italian)/.*$"; string rep = @"http://$2.$1/"; return Regex.Replace(url, pat, rep);}結(jié)果: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 關(guān)注
- 144 瀏覽
添加回答
舉報
0/150
提交
取消