私はフォームに文字列を持っています[abc].[some other string].[can.also.contain.periods].[our match]
私は今、文字列「私たちの試合」(つまり、括弧なし)に一致させたいので、ルックアラウンドなどで遊んだ。正しい一致が得られましたが、これはきれいな解決策ではないと思います。
(?<=\.?\[) starts with '[' or '.['
([^\[]*) our match, i couldn't find a way to not use a negated character group
`.*?` non-greedy did not work as expected with lookarounds,
it would still match from the first match
(matches might contain escaped brackets)
(?=\]$) string ends with an ]
言語は .net/c# です。正規表現を使用しないより簡単な解決策があれば、私も知りたいです
私を本当にいらいらさせているのは、(.*?)
後読みでは非貪欲が機能しないように見えるため、文字列をキャプチャするために使用できないという事実です。
私も試しました: Regex.Split(str, @"\]\.\[").Last().TrimEnd(']');
、しかし、私はこの解決策を本当に誇りに思っていません