Ask Your Question
2

Find & Replace including a Paragraph Mark

asked 2012-08-08 06:13:07 +0200

Oldbwl gravatar image Oldbwl
63 1 2 10

updated 2013-01-27 22:36:58 +0200

manj_k gravatar image manj_k
5962 4 35 53

I write macro's in Word to refine OCR'd documents. a frequently used one is

Find: ", ^p" and Replace: ", " to join sentences which were split with the 1st half ending in a comma and space.

Now I have converted to Linux 100% (hooray!!!) and LibreOffice (hooray!!!!) I am finding it very difficult to easily reproduce the same work-flow. I am no Regex aficionado but I have researched the "common Regular Expressions" wiki page plus several other forums etc, and find no really simple answer - seems a feature request is in order.

But before that assuming I missed something, do any of you have a really simple answer to this? I frequently want to include a Para mark in my search and/or replace. - I use \n in the Replace bit. If I have to use a "U+code" how exactly is this typed in?

Many thanks Dan

delete close flag offensive retag edit

6 Answers

Sort by » oldest newest most voted
2

answered 2012-08-08 10:28:39 +0200

mariosv gravatar image mariosv flag of Spain
5039 23 51

I think this extension can help:

http://extensions.libreoffice.org/extension-center/alternative-dialog-find-replace-for-writer

link delete flag offensive edit

Comments

This does do the job, so thanks for that. I will have to play around with this extension to find out why when I record a macro and use it, the extensions aspect is ignored. However, I notice it has its own batch commands and keyboard shortcut facility, so I think maybe they will replace the macros

Oldbwl ( 2012-08-08 12:46:21 +0200 )edit
1

answered 2012-08-08 07:17:35 +0200

Pedro gravatar image Pedro flag of Portugal
3333 4 26 56

Did you enable the Regular Expressions option?

http://ask.libreoffice.org/question/1491/findreplace-not-recognizing-t-for-tabs/

link delete flag offensive edit
0

answered 2012-12-01 11:58:27 +0200

David gravatar image David flag of United Kingdom
772 2 23 27

It's not a direct answer to your question, but have a look at the pair of answers on quotation marks (that one linked, and the one below it). One is about assiging macros to menus, etc., the other is about regex in relation to quotation marks.

In the latter post there is also a link to a discussion in an OpenOffice forum explaining the regex statements used which, I think, will help solve your own paragraph issue here. If I get a moment, I'll have a stab at constructing one myself, but maybe that's enough to get you going. (Give someone a fish..., teach someone to fish..., etc.!)

link delete flag offensive edit
0

answered 2012-12-01 10:37:59 +0200

ugm6hr gravatar image ugm6hr
1

If you enable (tick) "Regular Expressions" in the find & replace box, the $ sign indicates a paragraph mark for searching.

So: Search: ", $" Replace: ", "

link delete flag offensive edit
0

answered 2012-08-08 08:08:56 +0200

Oldbwl gravatar image Oldbwl
63 1 2 10

Yes I have enabled the regular expressions option, of course. My reference to already using \n ought to have indicated that, sorry for not being clearer. I know I can search for \t, as I found that in my searches before asking my question.

In Word you can search for ", ^p" (i.e. comma, space, paragraph mark, no speech marks) and replace with ", " (comma, space, no paragraph mark) which will remove the paragraph mark. Simple, powerful and can be extended for all sorts of operations.

There appears to be no straight simple method of doing this in LibreOffice - there is no \p like the \t and \n etc.

I Know I can search "^$" and replace "" to remove empty paras, but my requirement is to remove just the para-mark depending on what I find immediately before it. Finding a comma or lower case letter immediately followed by the para-mark indicates a broken sentence, I want to test for that and remove the para-mark.

I know I can test for [a-z]$ etc, but I can't find a way to just delete the end of Para mark when it finds them.

link delete flag offensive edit
0

answered 2012-12-05 15:58:59 +0200

adaca gravatar image adaca
1

Search for [a-z]+$[a-z]+ (the + is for 1 or more occurence).

Now please someone do help with the "Replace with" part, as I'm having troubles myself trying to recall in the usual way \1, \2, ecc. the strings found with the search regexp...

And, moreover, the Alternate Find&Replace extension always throws a Basic Exception when I try to replace with "all text" &, and/or \1 \2 ecc....

link delete flag offensive edit

Comments

Look for "regular expression" in the index tab of LibreOffice help, you can find what you are looking for?

mariosv ( 2012-12-05 22:35:11 +0200 )edit

Login/Signup to Answer

Donate

LibreOffice is made available by volunteers around the globe, backed by a charitable Foundation. Please support our efforts: Your donation helps us to deliver a better product!

Question tools

Follow
1 follower

subscribe to rss feed

Stats

Asked: 2012-08-08 06:13:07 +0200

Seen: 2,521 times

Last updated: Dec 05 '12