Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想fish egg chicken beef在句子中捕获组How much is fish egg chicken beef ?。我试过了
fish egg chicken beef
How much is fish egg chicken beef ?
how much is ((?>\w+))* \\?
但它只fish作为第二组返回。我在这里做错了什么?
fish
也许正则表达式应该是:
How much is (.*)\?
或者,如果您想在每次捕获中匹配除一个单词之外的所有单词:
How much is (?:(\w+)\s*)+\? Regex regexWords = new Regex(@"How much is (?:(\w+)\s*)+\?"); foreach(Capture word in regexWords.Match(input).Groups[1].Captures) { // word.Value contains one word. }
祝你的任务好运。