在没有第一个的情况下反转数组中的所有单词

Asp*_*ruh 3 .net c# regex

我试图让以下代码工作,所以如果

输入是:你好吗?

输出应该是:

eud怎么样?

我认为我非常接近完成它但我无法理解为什么,正则表达式不起作用它不被识别.这是repl:https://repl.it/MHzu/1

using System.Collections.Generic;
using System.Linq;
using System;
using System.Text.RegularExpressions;

public class Kata
{    
   static void Main(string[] args)
    {
          string str = Console.ReadLine();            
          string opaa = str;
          Match m = Regex.match(str,"(\w*) (\w.*)");
          string hoho = m.Groups[1];
          string strrev = "";
          foreach (var word in opaa.Split(' '))
          {
              string temp = " ";
              foreach (var ch in word.ToCharArray())
              {
                 temp = ch + temp;
              }
              strrev = strrev + temp + "";
          }
          Console.WriteLine(hohoo + strrev);  
    }
}
Run Code Online (Sandbox Code Playgroud)

Ese*_*ser 5

你也可以使用Linq

string input = "think that I am very close to finish";

var  output = string.Join(" ",input.Split()
                                   .Select((x, i) => i == 0 ? x : string.Concat(x.Reverse())));
Run Code Online (Sandbox Code Playgroud)

  • 对不起,但非常*例子*`你好吗?`是一个*计数器的例子*:期待`怎么样的时代edud?`实际`时代如何udu?edud`(请注意问号`?`) (2认同)