Description: I had a file with the end of sentences ending with a fullstop, then a space and then a newline. I used the search and function faciity to remove the space before the end of line, so I put "space and \n" to search for the end of lines preceded by a space. I then put "\n" in the resplace box. What actually happened was the space is removed but the end of line is replaced with end of string. Steps to Reproduce: 1.Try to remove characters before a "new line" non-printing characther with the search and replace facility with the Regex option on. 2.Use a "new line" expression "\n" without the preceding character, becasue the desired effect is to remove the characters before the new line. 3.Look at results. The \n is replaced with end of string. Actual Results: As above. Expected Results: It should have known tha \n is a new line, but it used end of string instead. Reproducible: Always User Profile Reset: No Additional Info: I will add a writer document that can be used to show that the search and replace function is not working correctly
Created attachment 199112 [details] writer document to use as a test case. Use this simple writer document to test the regex to search and replace a "new-line" of "\n". It will not work correctly. It will replace the end of lines with an end of string, which is not what is expected.
You can also do tests to show that replacing an end of string character with an end of string character does not work. There should be no change, but it replaces the end of string with the litoral character $, and it does not seem to know that $ means end of line when regex is switched on. The regex should handle \n and $ corrected, but there are bugs for both.
I *assume*, that by "end of string", you meant "end of paragraph", which what actually gets created. Please check the documentation for the regular expressions in LibreOffice [1]: > \n When entered in the Replace text box in Writer, inserts a paragraph break that can be inserted with the Enter or Return key. This works as designed. 1. It's impossible to have line break in replacement string: bug 45344, bug 106137. 2. In your case, you can use look-ahead assertion: search for ' (?=\n)' (without quotes), and replace with nothing. [1] https://help.libreoffice.org/latest/en-US/text/shared/01/02100001.html?&DbPAR=WRITER
Please review the documentation [1] The Replacement field does not parse ICU regex, and Replacement with "\n" is handled as a marker for ODF Paragraph object end. They are not "end of string" rather they have been converted to paragraph ends. =-ref-= [1] https://help.libreoffice.org/latest/en-US/text/shared/01/02100001.html?DbPAR=WRITER *** This bug has been marked as a duplicate of bug 108256 ***