string str = "On the screen the faint, old, robed figure of Mercer toiled upward, and all at once a rock sailed past him.";
搜索子串:
string find = "figure of";
获得所需的输出:
figure of Mercer
慕田峪7331174
浏览 126回答 1
1回答
慕标琳琳
你可以试试这个模式 ([inputString] +(\\w+))使用正则表达式group和空格来获取单词。string search = "figure of";string str = "On the screen the faint, old, robed figure of Mercer toiled upward, and all at once a rock sailed past him.";string regex_Str = string.Format("({0} +([\\w+]+))", search);var result = new Regex(regex_Str).Match(str);Console.WriteLine(result.Value);