1,)string a=" babaasd asdbsd bbdscc";把string a里面的,每个(看作单词吧)的b字母移当最后去
    
    babaasd asdbsd bbdscc
结果aaasdbb asdsdb dsccbb 2,)string b=" babaasd123*asdbsd   //3bbdsccg/re              ert*f5";我想获取ert*f5..也就是获取最后string b里的最后一个字符串(也就是从最后一个字符(ert*f5中的5)反过来匹配到空格之前的就行了)..不知道怎么写..

解决方案 »

  1.   

     string a = " babaasd asdbsd bbdscc";
                a = Regex.Replace(a, @"\w+", delegate(Match m)
                {
                    string str = m.Value;
                    return Regex.Replace(str, "b", "") + Regex.Replace(str, "[^b]", "");
                });
      

  2.   

     string b = " babaasd123*asdbsd   //3bbdsccg/re              ert*f5";
                b = b.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Last();
              
      

  3.   

    2. string result=Regex.Split(b,"\\s+").Last();
      

  4.   

    void Main()
    {
    string a=" babaasd asdbsd bbdscc";
    var query=from x in a.Split(' ')
              let y= x.ToCharArray().OrderBy(s=>s=='b'?1:0)
      select new string(y.ToArray());
    Console.WriteLine(string.Join(" ",query.ToArray()));  // aaasdbb asdsdb dsccbb}
      

  5.   

    string a="babaasd asdbsd bbdscc";
    a = a.Split(' ').Select(o => o.Replace("b", "") + new string('b', o.Count(p => p.Equals('b')))).Aggregate((sum, next) => sum + " " + next);
    string b = " babaasd123*asdbsd   //3bbdsccg/re              ert*f5";
    b = b.Split(' ').Last();