如何在datatable列中提取值

时间:2009-11-20 09:17:05

标签: asp.net

数据表名称:图像 在那之下,我有一个名为image

的列
under(image column) i have   values 
image1-school
image2-college
image3-mba

现在我需要从该列中仅提取学校大学MBA值   并在复选框列表中绑定这些值

如何实现这一目标

谢谢

1 个答案:

答案 0 :(得分:0)

// first I need to create a match to see if the input string is in the corrent form
Match match = Regex.Match("image1-school", @"^image\d-(.*)$", RegexOptions.IgnoreCase);
// the parenthesis in the Regular Expression meeans the content must be place in a group
// as groups are 1 based, the first group is group[1]
if (match.Success)
{
     // this string will have the value of whatever was within the parenthesis
     string theStringYouWant = Regex.Match("image1-school", @"^image\d-(.*)$", RegexOptions.IgnoreCase).Groups[1].Value;
}