Ask Your Question

Regular Expressions not working as expecting: remove a line [closed]

asked 2016-10-17 13:50:14 +0100

MatthijsG gravatar image

updated 2020-07-26 01:06:01 +0100

Alex Kemp gravatar image

When doing a Search&Replace with regular expressions, the following search removes a complete blank line (=only an enter)


I've to Search&Replace often text like 'label foobar: #N/A'. Therefore, i use


This expression removes the unwanted text, but doesnt remove the line.

And my question is, why not?

In the first case, the preview highligts the whole line. With the second code, only 'till the enter-mark

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2020-07-26 01:07:31.603189

4 Answers

Sort by » oldest newest most voted

answered 2016-10-17 18:17:31 +0100

updated 2016-10-17 18:18:42 +0100

Tried, at least by what I know about RegEx, you can't delete the newline with a RegEx. Tested expressions in LO

edit flag offensive delete link more


Yay, Finland. Writer's regular expression support is abysmal at best, at least in regards to new line characters. I'm encountering this problem now, and it's very annoying.

PhLo gravatar imagePhLo ( 2018-12-04 05:29:54 +0100 )edit

answered 2016-10-17 14:19:37 +0100

erAck gravatar image

The ^$ empty sequence is a special case expression. In all other expressions the ^ and $ are anchors to the expression.

edit flag offensive delete link more


^$ is supposed to mean empty line. If it doesn't it's violation of the standard.

rautamiekka gravatar imagerautamiekka ( 2016-10-17 18:13:32 +0100 )edit

But ^something$ is something different. What standard btw?

erAck gravatar imageerAck ( 2016-10-18 15:04:59 +0100 )edit

RegEx is mostly identical between implementations, with Perl's being the sanest. Without checking I don't know if there's an actual standard shown to the authorities, but not everything's been standardized that way.

rautamiekka gravatar imagerautamiekka ( 2016-10-18 15:37:23 +0100 )edit

answered 2016-10-17 22:01:08 +0100

RGB-es gravatar image

Just to add a bit of information: RegExp on Writer only work within a paragraph and that's why you cannot select part of the text and the paragraph end.

You may try with AltSearch extension, which offers more functionality than the default LibO S&R tool.

edit flag offensive delete link more

answered 2016-10-18 10:41:40 +0100

pierre-yves samyn gravatar image


As @RGB-es said you can do this with AltSearch extension:

  • search for: ^.+#N/A$\p
  • replace with nothing

AFAIK it is not possible to do it without the extension in one shot. You have to:

  1. Replace empty paragraphs with a text that is not in the document (e.g. µLIBOµ)
  2. Replace ^.+#N/A$ with nothing (you get new empty paragraphs)
  3. Replace empty paragraphs with nothing
  4. Replace µLIBOµ with \n (recreate the "good" empty paragraphs)


edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-10-17 13:50:14 +0100

Seen: 448 times

Last updated: Oct 18 '16