Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index

2013/1/9 Johnny Rosenberg <>:
2013/1/9 Johnny Rosenberg <>:
2013/1/9 gordom <>:
W dniu 2013-01-09 07:17, Brian Barker pisze:

At 19:58 08/01/2013 +0100, Gordom Noname wrote:

I would appreciate your help with the regular expressions. I have a
document consisting of hundreds of lines. A small sample is here:

Set:   01SA34509
Set:   0134501
Set:   0111679SE

I need to delete all text except these lines started with word "Set".
If I use "set:.+" regular expression, all these lines, that should be
kept, are selected. I cant find a way to reverse this selection. I
tried "[^set:.+].+" and "[^(set:.+)].+" but they don't work. Could you
please give me any clues?

I think this is fairly simple.  I'm assuming that your "lines" are
actually separate paragraphs, in fact: that they are separated by
paragraph breaks, not line breaks, that is.

o Using Find & Replace with "Regular expressions" ticked, search for
^Set and click Find All. This will select just those words, where they
occur at the start of a line, not the whole lines.
o Click the down-arrow at the right of the Apply Style window in the
Formatting toolbar, and select some (paragraph) style different from the
style of your text (perhaps Heading?).  Since this is a paragraph style,
it will apply to the whole of each relevant line (paragraph), not just
the selected occurrences of the word "Set".
o Back in the Find & Replace dialogue, click "Search for Styles", choose
your original style (perhaps Default?) in the "Search for" box, and
click Find All.
o Press Delete to remove all the unwanted lines.
o Tick "Regular expressions" again, and search for ^$ - replacing with
nothing.  Click Replace All.  This removes the empty paragraphs left by
the previous process.
o Go to Edit | Select All (or press Ctrl+A) and use the Apply Style
window again to reset your paragraph style appropriately (to Default?).

I trust this helps.

Brian Barker

It seems to work indeed. Thank you very much :-). Regards,


This worked for me with your example lines a minute ago:

Ctrl+h (or whatever method you prefer for opening the Search and
Replace dialogue).
☒ Regular expressions
Search for: ^[^S][^e][^t].*$
Replace with: (leave empty)
Click Replace All

Search for: ^$
Leave everything else as is
Click Replace All.


The funny thing is that the last part didn't work for me maybe ten
minutes ago, but I must have done something slightly different that

So, in short terms:
1. Replace all ^[^S][^e][^t].*$ with nothing (regular expressions on).
2. Replace all ^$ with nothing (regular expressions still on).

Step 1 would also erase lines starting with ”set” and ”SET”, so if you
want to keep all possible combinations for the word ”set”, you should
rather try: ^[^Ss][^Ee][^Tt].*$
I didn't try that myself, but it should work. There is always Undo if
it doesn't…

Kind regards

Johnny Rosenberg

Okay, forget it. This keeps everything that starts with an S, not only
the Set lines…
If that's not at problem, this is a fast way, otherwise it could
require quite some manual work or further Seach and Replace
I'll give it a few more thoughts…

Kind regards

Johnny Rosenberg

Another method:
1. Ctrl+h, Search for: ^Set.*$
2. ☒ Regular expressions, click Search all. Close the dialogue.
3. Ctrl+x Ctrl+a Ctrl+v Ctrl+h
4. Search for: Set
5. Replace with: \nSet
6. ☒ Regular expressions, click Replace all. Close the dialogue.
7. Remove the first line, which now is empty, manually.

Looks like many steps, but it is quick, actually.

Kind regards

 Johnny Rosenberg

For unsubscribe instructions e-mail to:
Posting guidelines + more:
List archive:
All messages sent to this list will be publicly archived and cannot be deleted


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.