How to extract required string in below text using regular expressions in java?JAVA

Программисты JAVA общаются здесь
Anonymous
How to extract required string in below text using regular expressions in java?

Сообщение Anonymous »

Я хочу извлечь строку между первым и последним в приведенном ниже тексте.

Код: Выделить всё

"Select statement"+"\n"+
"first"+"\n"+
"I want to extract this" +"\n"+
"I want to extract this one too"+"\n"+
"last"+"\n"+
"end of the statement"+"\n"+
"first"+"\n"+
"I want to extract this" +"\n"+
"I want to extract this one too"+"\n"+
"last"+"\n"+
"end of the statement"
< /code>

Сценарий 2: < /p>

"Select statement"+"\n"+
"first"+"\n"+
"I want to extract this" +"\n"+
"last"+"\n"+
"end of the statement";
What would be the regex pattern in java to do this job? Pattern should be one but it should work in both the scenarios. Thanks for your help.

Подробнее здесь: https://stackoverflow.com/questions/325 ... ns-in-java

Вернуться в «JAVA»