语境
我从这样的数据库中检索网站列表:
DashboardEntities dashboardDB = new DashboardEntities();
var sites = dashboardDB.Instances
.Select(attr => new SiteModel
{
server = attr.server,
pool = attr.pool,
url = attr.url,
version = attr.version,
client = ???
})
.ToList();
return sites;
对于client
,我需要从 url 中获取一个子字符串,如下所示:
String client = "";
Regex rgx = new Regex(@"\.[a-z-./]+");
client = rgx.Replace(attr.url, "");
rgx = new Regex("formation-");
client = rgx.Replace(client, "");
问题
如何使用正则表达式对我的 LINQ 查询进行此字符串操作?