【发布时间】:2018-07-20 01:57:26
【问题描述】:
在:
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";
如果这样:
string reg = string.Format("({0} +([\\w+]+))", find);
var result = new Regex(reg).Match(str);
我可以得到部分跟随搜索的句子:
figure of Mercer
但是如何在搜索的句子之前找到短语的一部分:
On the screen the faint, old, robed
并且只获取最近的单词:
robed
【问题讨论】:
标签: c# regex string linq substring