How to search and replace for special characters in LibreOffice / OpenOffice Writer?

14

2

I love LibreOffice / OpenOffice, but some tasks cannot be done in it, such as is mentioned in this question's title, to search and replace for special characters in Writer. Does anyone know how to do this?

This can be done with MS Word (for instance, searching for the paragraph mark "^p", and replace it with a tabulation "^t").

This can also be done in Notepad++ (in given example, using "\n" and "\t").

But in Writer, although there is the option "regular expressions", I cannot search for special characters with it - I always have to copy+paste text to MS Word/Notepad++, do what I want and copy+paste back to Writer...

Edit #1: for the tabulation mark it works when searching for \t.

What about with paragraph marks or line breaks? It does not seem to . I've already tried \r, \n, \r\n, \n\r, ^p, ^l...

Edit #2: Almost solved by @Linker3000, but what about paragraph marks?

kokbira

Posted 2011-06-17T12:55:18.147

Reputation: 4 883

2The $ sign will search for a paragraph mark, but not replace with one. – None – 2012-01-23T20:40:56.983

Answers

8

You can certainly use regular expressions in LibreOffice 3.4 as I have just tried it:

enter image description here

There's a fuller list of what can and can't be used here:

http://help.libreoffice.org/Common/List_of_Regular_Expressions

Edit: There's some comments on how to deal with paragraph marks here:

http://www.oooninja.com/2007/12/example-regular-expressions-for-writer.html

Linker3000

Posted 2011-06-17T12:55:18.147

Reputation: 25 670

but what about paragraphs, line breaks...? – kokbira – 2011-06-17T14:18:51.883

Try the regex expressions like \n – Linker3000 – 2011-06-17T18:45:21.903

With tabulation mark functions, but paragraph or line breaks it does not. I've already tried \r, \n, \r\n, \n\r, ^p, ^l... – kokbira – 2011-06-17T18:54:25.747

http://help.libreoffice.org/Common/List_of_Regular_Expressions – Linker3000 – 2011-06-17T19:43:50.957

I.e., it is impossible to do a single search for paragraph marks :( You can search for line breaks "shift+enter" (or a <br> in html) with "\n". You can search for a text in a beginning of a paragraph, like "^thing" will search for a text "thing" that is in beginning of a paragraph. But paragraph mark no! :( Think that: I have a long text and I want to change all occurrences of "two enters" (not "shift-enter") with "one enter" (not "shift-enter"). How to do that? In MS Word, it's only replace of "^p^p" with "^p"... – kokbira – 2011-06-17T20:25:25.803

+1 for solution for all other problems than paragraph mark search :) pls, include link in the answer. – kokbira – 2011-06-17T20:28:08.703

"You aren't evil", Linker3000, so, I'll give you the best answer. Although I continue to cannot do a search for double paragraph marks to replace with single paragraph marks (in MS Word, from "^p^p" to "^p", now I can do a search for empty paragraphs and replace with nothing (in OpenOffice, from "^$" to "") generating the same results. – kokbira – 2011-06-19T04:54:23.860

2

Even better (in my opinion) to do it with AltSearch. See this post. In the GUI of AltSearch You'll easily find codes all the non-printing chars and much more.

Adobe

Posted 2011-06-17T12:55:18.147

Reputation: 1 883

Are there any official download link? How to use it? – kokbira – 2013-04-22T12:43:28.173

It looks like got renamed to Alternative dialog Find & Replace for Writer. Ages ago I used to code regular expressons in ~/.config/libreoffice/3/user/config/AltSearchScript.txt (I'm on linux) -- then I would assign them hotkeys using AltSearch GUI. I coded quite a number of text tranformations this way. Which exactly do You need?

– Adobe – 2013-04-22T21:13:36.507

Only an effective way to replace tabulation marks with paragraph marks and vice-versa... E.g., I use that to transform some data organized in lines to spreadsheets. Currently, I use more than one application to do that if using Libre Office / Open Office. With MS Office it is so easy - on Word: 1) replace all ^p^p with ^l, 2) replace all ^p with ^t, 3) replace all ^l with ^p, 4) ctrl+a, ctrl+c; On Excel: 1) ctrl+v... – kokbira – 2013-04-23T12:30:43.983

I would suggest posting sample data: how it looks like after Ctrl-v. Then how You'd like to be -- after transformation. I'm sure it is possible with altsearch. It also might be possible with default LibreOffice find-replace. Please start a question and give a link here. – Adobe – 2013-04-23T13:05:58.537

0

astangl

Posted 2011-06-17T12:55:18.147

Reputation: 1

1Add a bit of detail, please. – vonbrand – 2013-04-20T14:28:23.050

I installed that extension, but how to use it? – kokbira – 2013-04-22T12:38:28.870

Hmmm... The same suggestion as @Adobe? – kokbira – 2013-04-22T12:42:07.403