110,539
社区成员
发帖
与我相关
我的任务
分享
string propertyValue = "8-35;8-36;9-49;10-65;19-136;21-142;22-145;29-148;158-592;";
string value = string.Empty;
int propertyID = 8;
string pattern = string.Format(@"(?<=^|\s+?|\D+?){0}-(?<key>[0-9]*);", propertyID);
string _result = string.Join(",",Regex.Matches(propertyValue, pattern).Cast<Match>().Select(a=>a.Groups["key"].Value));
//35,56
string value = string.Empty;
string pattern = string.Format("{0}-(?<key>[0-9]*);", propertyID);
MatchCollection matchs = Regex.Matches(propertyValue, pattern);
if (matchs != null)
{
foreach (Match match in matchs)
{
if (match != null)
{
value += match.Groups["key"].Value + ",";
}
}
}
// 移除最后一个,号
if (value.Length > 0) value = Common.StringHelper.Remove(value, ",");