Deleting a line of text

Hi team
I am trying to delete a line of text in docx using Aspose words java.
The input and output using aspose is like this.

Input
Line 1
Line 2
Line 3
Line 4

Output
Line 1

Line 4

I don’t want those line breaks. How can I achieve this?

FindReplaceOptions findReplaceOptions = new FindReplaceOptions();
findReplaceOptions.setDirection(FindReplaceDirection.FORWARD);
findReplaceOptions.setFindWholeWordsOnly(true);
findReplaceOptions.setMatchCase(true);

document.getRange().replace(text, "", findReplaceOptions);

@gkumar16 If each line is a separate paragraph in your document, you can use &p metacharacter to match it with the text. For example see the following code:

Document doc = new Document("C:\\Temp\\in.docx");
doc.getRange().replace("Line 2&p", "");
doc.save("C:\\Temp\\out.docx");

If the lines are separated by soft line break (Shift+Enter), the you can use ControlChar.LINE_BREAK:

Document doc = new Document("C:\\Temp\\in.docx");
doc.getRange().replace("Line 2" + ControlChar.LINE_BREAK, "");
doc.save("C:\\Temp\\out.docx");