私は Java を使用しており、2 つの異なるシナリオに適合する 2 つの正規表現を作成したいと考えています。
1:
STARTText blah, blah
\ next line with more text, but the leading backslash
\ next line with more text, but the leading backslash
\ next line with more text, but the leading backslash
最初の行がバックスラッシュで始まらなくなるまで。
2:
Now you will see the following links for the items:
1111 leading 4 digits and then some text
2565 leading 4 digits and then some text
8978 leading 4 digits and then some text
このブロックは、たとえば 8978 の後に空の行が追加されて終了します。ただし、さらに、開始桁のブロックが 10 回繰り返されて終了することもわかっています。
したがって、個々の行をフィルタリングすることは何とか可能ですが、間に複数の改行を入れてそれを行うにはどうすればよいでしょうか? そして、いつ/どのように終了するのか本当にわからない最初のブロックでも。また、バックスラッシュの検索。したがって、私のアプローチは、1 つだけの閉じた式を持つことです。これは、replaceAll() にも使用できます。