日期:2014-05-17 浏览次数:20554 次
string s = "1、程序员啊程序员、好苦逼啊、好苦逼。"
string result = string.Join("、", s.Split('、').Select((x, i) => i == 1 ? "已" + x " x).ToArray());
------解决方案--------------------
好,我给个正则的吧
string s = "1、程序员啊程序员、好苦逼啊、好苦逼。";
Regex regex = new Regex(@"、");
string r = regex.Replace(s, "$0已", 1);
Response.Write(r);
------解决方案--------------------
string s = "1、程序员啊程序员、好苦逼啊、好苦逼。";
s=s.Insert(s.IndexOf('、')+1, "己");
------解决方案--------------------
string s = "1、程序员啊程序员、好苦逼啊、好苦逼。2、哈哈哈。3、呵呵呵";
Regex regex = new Regex(@"\d+、");
string r = regex.Replace(s, "$0已");
Response.Write(r);
------解决方案--------------------
string s = "1、程序员啊程序员、好苦逼啊、好苦逼。"
string result = string.Join("、", s.Split('、').Select((x, i) => i == 1 ? "已" + x : x).ToArray());
------解决方案--------------------
string s = "1、程序员啊程序员5、好苦逼啊6、好苦逼。2、已哈哈哈、7哈哈。3、已呵呵呵、呵呵";
Regex regex = new Regex(@"\d+、");
string r = regex.Replace(s, "$0已", 1);
Response.Write(r);
------解决方案--------------------
string s = "1、程序员啊程序员5、好苦逼啊6、好苦逼。2、哈哈哈、7哈哈。3、呵呵呵、呵呵";
int temp = 0;
string r = Regex.Replace(s, @"(\d+)、", delegate(Match match)
{
string result = match.Value;
int index = int.Parse(match.Groups[1].Value);
if (index == temp + 1)
{
result = match.Groups[0].Value + "已";
temp++;
}
return result;
});
Response.Write(r);