| ■No94912 (OA さん) に返信 > 理解できないのは、 > 外カッコの (?: .) ★ここが何をしているのか、わからない > (?:)はグループとしてキャプチャしないですよね?
Groups が変化します。
Regex.Matches("0開始12開始34終了56開始78終了9", "開始(?:(?!開始).)*終了") Index= 5,Length= 6,Value=【開始34終了】,Groups=[開始34終了] Index=13,Length= 6,Value=【開始78終了】,Groups=[開始78終了]
Regex.Matches("0開始12開始34終了56開始78終了9", "開始((?!開始).)*終了") Index= 5,Length= 6,Value=【開始34終了】,Groups=[開始34終了][4] Index=13,Length= 6,Value=【開始78終了】,Groups=[開始78終了][8]
Regex.Matches("0開始12開始34終了56開始78終了9", "(開始(?:(?!開始).)*終了)") Index= 5,Length= 6,Value=【開始34終了】,Groups=[開始34終了][開始34終了] Index=13,Length= 6,Value=【開始78終了】,Groups=[開始78終了][開始78終了]
Regex.Matches("0開始12開始34終了56開始78終了9", "(開始)((?!開始).)*(終了)") Index= 5,Length= 6,Value=【開始34終了】,Groups=[開始34終了][開始][4][終了] Index=13,Length= 6,Value=【開始78終了】,Groups=[開始78終了][開始][8][終了]
Regex.Matches("0開始12開始34終了56開始78終了9", "(開始)(?:(?!開始).)*(終了)") Index= 5,Length= 6,Value=【開始34終了】,Groups=[開始34終了][開始][終了] Index=13,Length= 6,Value=【開始78終了】,Groups=[開始78終了][開始][終了]
|