■94917 / inTopicNo.8) |
Re[6]: 正規表現の後読み |
□投稿者/ 魔界の仮面弁士 (2737回)-(2020/06/03(Wed) 20:42:10)
|
■No94916 (魔界の仮面弁士) に追記 > 末尾に進むにしたがって、キャプチャーグループが上書きされていくものと理解しています。
https://docs.microsoft.com/ja-jp/dotnet/standard/base-types/alternation-constructs-in-regular-expressions
上記で使われている例文でいえば:
Regex.Matches("Yes. This dog is very friendly.", "((\w+)[\s.])+")
Matches(1).Groups(2) は、.Captures(*).Value = { "This", "dog", "is", "very", "friendly" }、.Value = "friendly" Matches(1).Groups(1) は、.Captures(*).Value = { "This", "dog", "is", "very", "friendly." }、.Value = "friendly." Matches(1).Groups(0) は、.Captures(*).Value = { "This dog is very friendly." }、.Value = "This dog is very friendly." Matches(1) は .Value = "This dog is very friendly." Matches(0).Groups(2) は、.Captures(*).Value = { "Yes" }、.Value = "Yes" Matches(0).Groups(1) は、.Captures(*).Value = { "Yes." }、.Value = "Yes." Matches(0).Groups(0) は、.Captures(*).Value = { "Yes." }、.Value = "Yes." Matches(0) は .Value = "Yes."
|
|