Page 1 of 1

[Solved] Replacing paragraph mark..

Posted: Wed Jul 30, 2008 6:37 pm
by maya90
hi,

how do you replace paragraph marks, tabs, etc.. in Open Office Writer? (in MS Word, you would type, for example, ^p for paragraph mark, but this is not working in Open Office.. how do you do this in OO pls..) thank you very much..

Re: replacing paragraph mark..

Posted: Wed Jul 30, 2008 7:37 pm
by acknak
OOo uses a far more powerful (but also far more complicated, and at the same time less complete) feature:
Regular Expressions in Writer [OOo wiki]

Re: replacing paragraph mark..

Posted: Wed Jul 30, 2008 7:46 pm
by r4zoli
Welcome on board,
before posting please read first, the Survival Guide, try to search on forum and you get the answers faster.

I think http://user.services.openoffice.org/en/ ... f=7&t=6818 this link gives answer your question, you problem using regular expression. Good tutorial on oooninja webpage.

Re: Replacing paragraph mark..

Posted: Fri May 20, 2011 1:29 am
by popeye
Oh dear. I have the same question: can someone tell me where to look for the answer please? I am not sure I have the time or the disposition to go and research regexp to find out how to perform a simple "search and replace for paragraph marks" operation.
Word makes it easy. BBEdit makes it easy.Why should it be so difficult in OpenOffice?
Thanks.

Re: Replacing paragraph mark..

Posted: Fri May 20, 2011 2:41 am
by acknak
There are a bunch of handy examples here: Regular expression samples [OOoNinja]

If you want specific suggestions, you'll have to tell us exactly what you're trying to do--replace paragraph marks with what? What are you trying to accomplish?

Re: Replacing paragraph mark..

Posted: Fri May 20, 2011 4:26 am
by popeye
Thanks acknak, but I am really not a programmer and cannot understand those examples. I am a plain, boring user, trying to move away from MS Office. I didn't realise it could be so time consuming.
So I'll try to explain what I am trying to accomplish, although I assure you I have no need to consider examples when performing Search and Replace operations in all the other text editors/word processors I am familiar with (Word, BBEdit, Nisus, TextEdit, many others).
In this particular case, I wanted to reflow some text where an email program had broken off the lines at 80 characters or so. In BBEdit (for example), I know I can do that by entering \n in the search field, and whatever value I wish in the replace field (could be a space, a tab, a || or any other "marker" if I wish). So how do I accomplish this in OO Writer? Thanks.

Re: Replacing paragraph mark..

Posted: Fri May 20, 2011 7:57 am
by MrProgrammer
Take a look at Alternative dialog Find & Replace for Writer. If the page is slow to load, try again later. They seem to be making infrastructure changes to some of the OOo pages and sometimes they aren't available.

Re: Replacing paragraph mark..

Posted: Fri May 20, 2011 2:51 pm
by acknak
Edit > Find & Replace
Search for: $
Replace with: space (or whatever)
Options/Regular expressions: ON (checked)

Click "Replace all".

Note that this is a special case. When you use "$" all alone, it is treated as the actual line break for purpose of replacement. That is not the case when you use $ along with other things in the "Search for" field. For example, you can't use "$$" to search for two consecutive line breaks.

Re: Replacing paragraph mark..

Posted: Thu May 26, 2011 4:31 am
by popeye
Edit > Find & Replace
Search for: $
Replace with: space (or whatever)
Options/Regular expressions: ON (checked)

Click "Replace all".
Great. Thank you acknak, this is exactly what I was looking for. Appreciate your help :-)

Re: Replacing paragraph mark..

Posted: Thu May 26, 2011 4:34 am
by popeye
MrProgrammer wrote:Take a look at Alternative dialog Find & Replace for Writer. If the page is slow to load, try again later. They seem to be making infrastructure changes to some of the OOo pages and sometimes they aren't available.
Thanks Mr Programmer. I'd prefer a built-in function, as in all the other "writers" I've used. Do you know whether future OO versions might include this alternative/extended search&replace funcionality?

Re: [Solved] Replacing paragraph mark..

Posted: Tue Aug 16, 2011 12:00 am
by jameskhazar
I've spent years avoiding learning regexp sytnax, it's serious overkill for such a simple (and often necessary) search and replace. It comes up often for me, like copying from a web page of a data table. For some reason the copy created a set of tabs and paragraph insertions that made it impossible to paste into a spread sheet. Simple to do in Word, find and replace ^t^p^t with ^t. After a half an hour's research and attempts with regex, still can't get it to work. I thought OpenOffice wanted to be on an even keel with MS Word. The lack of this one thing may force me to go back...

Re: [Solved] Replacing paragraph mark..

Posted: Tue Aug 16, 2011 3:06 am
by mriosv
There is an extension to do it:
Alternative searching 1.3.2 (AltSearch.oxt)
Copyright (c) 2007 Tomas BILEK
http://extensions.services.openoffice.o ... /AltSearch

Re: [Solved] Replacing paragraph mark..

Posted: Fri Jan 23, 2015 7:54 pm
by arndtwc
I will agree with what jameskhazar said on Mon Aug 15, 2011 6:00 pm. I want to search for a paragraph marker and replace with two paragraph markers. Simple to do in MS Word. But Openoffice it is not possible. I am going back to MS Word.

Re: [Solved] Replacing paragraph mark..

Posted: Fri Jan 23, 2015 8:02 pm
by RoryOF
Wrong, wrong wrong!

Use Find and Replace. In Find box put $. In Replace box put \n\n. Drop More Options, check Regular Expressions, then do either single Replaces, or Replace All.

But if you are happier with MS Word, off you go.

Re: [Solved] Replacing paragraph mark..

Posted: Fri Jan 23, 2015 8:06 pm
by acknak
arndtwc wrote:... I want to search for a paragraph marker and replace with two paragraph markers. ...
Edit > Find & Replace
Search for: $
Replace with: \n\n
Options/Regular expressions: ON

Click Replace All

Note: The replacement does not seem to happen for the last paragraph in the document, for some reason.

Re: [Solved] Replacing paragraph mark..

Posted: Wed Jan 28, 2015 8:37 pm
by John_Ha
arndtwc wrote:I am going back to MS Word.
Be sure to let us know if the MS Word forum is as good as this AOO forum for helping users to solve problems.

Re: [Solved] Replacing paragraph mark..

Posted: Wed Jan 28, 2015 10:34 pm
by Lupp
Ok. I've noticed the topic being marked [Solved].
What I missed - and still cannot find: How was it solved?

The original subject was: "Replacing paragraph mark.." .

I agree that we possibly haven't to replace an actual character (or2). It's about merging 2 or more paragraphs into one - and there will surely be implications (think alone of the complicated paragraph styles). This aside, and possibly forced to accept imperfect results : How can I simply merge 3 empty paragraphs into one? This a surely not too excentric task - and often needed.

Even the possible shortcomings of the ICU engine for regular expressions accepted there should be a way to also actually find the paragraph break as something we can delete or replace by something else and not only as a condition restricting the acceptance of a pattern like a "word boundary" e.g. Using \n for 'hard line break' when searching but for 'new paragraph' when replacing is a grave oddity IMO. Approximately the same with using $n for the nth variable containing found text"glued-together".

Re: [Solved] Replacing paragraph mark..

Posted: Thu Jan 29, 2015 1:52 am
by acknak
Lupp wrote:... and still cannot find: How was it solved?
As far as I see, the problem is that there are several related questions being asked and answered.

The actual answer depends on the document content and exactly what you want to do with it.
... How can I simply merge 3 empty paragraphs into one? ...
This precise task is not possible with OO, unfortunately.

However, there is (maybe) a workaround: you can remove empty paragraphs using the pattern ^$ and replacing with nothing. This is handled as a special case (I believe).

As far as I understand, this is not a limitation in the ICU regex library, but in the way the document data is structured and accessed by the code. It seems that fixing it may require a large effort. The switch to ICU was a huge improvement; I hope it will be cleaned up someday.

All that aside, I do a lot of messy text clean up and OO's find & replace works well enough to get the job done, even with its limitations.

Re: [Solved] Replacing paragraph mark..

Posted: Thu Jan 29, 2015 3:01 am
by Lupp
Thanks "acknak"!
Writer is not the component of Office I use most (and I never use Impress) ... Nonetheless I had more than once the actual need to merge "superfluos multiple inter-paragraphs" into single ones. I had to do the most of it manually.

How costly an enhancement?

I already mentioned in my post above that the present 'Find & Replace' is not capable of inserting a hard line break. At least the search code \n for it will, used in 'Replace with', cause insertion of a new paragraph. (Do you know another representation stepping in for \n ?) That is (Sorry!) idiotic. And it is not related with deeply coded-in properties of the regex engine. I judge it to be a thoughtlessness. We need another helper for inserting paragraphs. And we need a "Find & Replace" dialogue passing the line-break U+000A represented by \n e.g.to the ReplaceDescriptor. That's all. You can test it: Find an existing pattern (\n)a and use the (Sorry again: idiotic!) paraphrase Q$1R in 'Replace with'. Yo will get what should be expected: Q followed by a hard line break followed by R. The engine is capable of it. The user interface isn't.

Re: [Solved] Replacing paragraph mark..

Posted: Thu Jan 29, 2015 1:30 pm
by John_Ha
... How can I simply merge 3 empty paragraphs into one? ...
Will something like this work?

1 Replace every paragraph return by some unused sequence like £*f3@#Q. This will mess up the document in spades :-)

2 Search for £*f3@#Q£*f3@#Q£*f3@#Q and replace it by £*f3@#Q. That converts the three to one.

3 Search for £*f3@#Q and replace it by a paragraph return, which should automagically restore the document.

Re: Replacing paragraph mark..

Posted: Fri May 28, 2021 2:47 pm
by Magnet8
acknak wrote:Edit > Find & Replace
Search for: $
Replace with: space (or whatever)
Options/Regular expressions: ON (checked)

Click "Replace all".

Note that this is a special case. When you use "$" all alone, it is treated as the actual line break for purpose of replacement. That is not the case when you use $ along with other things in the "Search for" field. For example, you can't use "$$" to search for two consecutive line breaks.
You are life savoir, my friend!