文字列を取得して、パターンのすべてのインスタンスとパターンのみを抽出する必要があります。
String test = "This is a test string to experiment with regex by separating every instance of the word test and words that trail test";
したがって、パターンはtest単語と、その前後の単語ではない単語を見つける必要がありtestます。したがって、基本的には、このパターンの 3 つのインスタンスが見つかる必要があります。
私が期待している3つの結果は次のとおりです。
This is a test string to experiment with regex by separating every instance of the wordtest and words that trailtest
私は gskinner で正の先読みと負の先読みをいじってみましたが、まだ運がありません。