当我在SharePoint 2010中获取列表从“作者”列的列表值,下面被显示:从字符串中删除数字
2;#SP10Setup
现在创建用户特殊的列表项是“SP10Setup”,现在有没有简单的方法去除SP10Setup开头的“2;#”而不影响“SP10Setup”中的数字?
我有,目前被剥离出来的所有数字
//method to strip out unnecessary digits
public static string RemoveDigits(string key)
{
return Regex.Replace(key, @"\d", "");
}
这是我得到的特定列表项值的方法:
string author = listItem["Author"].ToString();
我这是怎么删除不想要的数字和字符:
//calling the RemoveCharacter method
string noDigitsAuthor = RemoveDigits(author);
string cleanedupAuthor = noDigitsAuthor.Replace(";", "").Replace("#", "");
结果我从这个得到的是“SPSetup”,但理想的我想要的结果成为“SP10Setup”。
什么是实现这一目标的最快,最简单的方法...提前
哇这工作得很漂亮很简单,没有必要乱用正则表达式,并替换字符......非常感谢 –