Ask Your Question

Regular Expression "\n" doesn't work

asked 2018-04-27 12:54:37 +0200

erad67 gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2018-04-27 15:37:28 +0200

Grantler gravatar image

updated 2018-04-27 15:39:05 +0200


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: (German)

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

edit flag offensive delete link more


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

David gravatar imageDavid ( 2018-04-27 20:19:17 +0200 )edit

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

michael.oneill gravatar imagemichael.oneill ( 2020-01-09 15:38:28 +0200 )edit

answered 2018-04-27 13:37:57 +0200

David gravatar image

updated 2018-04-27 14:46:58 +0200

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!

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-04-27 12:54:37 +0200

Seen: 1,209 times

Last updated: Apr 27 '18