Regular Expression "\n" doesn't work

Searching for “\n” with Regular Expressions clicked finds nothing in a book long document. Any idea what the issue is? Searching “$” does find the end of paragraphs, so I know search and some regular expressions are working.

Actually, it does work. This behaviour is expected. To quote from the document linked, in LibO regex, \n varies whether it is in the “find” or “replace” field. It behaves as follows:

  • Represents a line break that was inserted with the Shift+Enter key combination. To change a line break into a paragraph break, enter \n in the Find and Replace boxes, and then perform a search and replace.
  • \n in the Find text box stands for a line break that was inserted with the Shift+Enter key combination.
  • \n in the Replace text box stands for a paragraph break that can be entered with the Enter or Return key.

So, to sum up – and as you have partially discovered – in LibO regex, \n in FIND matches a line break; $ in FIND matches a paragraph end.


To show the community your question has been answered, click the next to the correct answer, and (optionally!) “upvote” by clicking on the ^ arrow to express thanks. These are the mechanisms for communicating the quality of the Q&A in these systems. Thanks!

@erad67

In a German forum for OpenOffice a Mac user complained about the same problem. Neither the regular tool nor AltSearch.oxt did their work regarding \n. On LInux and Windows no problems.

See: https://de.openoffice.info/viewtopic.php?f=1&p=274860&sid=04826df1f37d1df2057c1f5b920db4a6#p274860 (German)

Please provide us with your used versions of OS and LO - and specify your query regarding *David’*s reply.

@grantler - it works just fine on my Mac (running Yosemite + LibO Vanilla 6.0.3.2). I wonder what the problem was for that OpenOffice user. (And it seems 4.1.5 is their current release.) Seltsam! :confused:

It doesn’t work on my mac (Mojave and 6.1.2.1) and it’s driving me nuts. Doesn’t recognize either \n or $.

1 Like