Ask Your Question
2

Find & Replace including a Paragraph Mark [closed]

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

Oldbwl gravatar image

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

manj_k gravatar image

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

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2015-10-19 03:26:43.707330

6 Answers

Sort by » oldest newest most voted
2

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

m.a.riosv gravatar image
edit flag offensive delete link more

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 gravatar imageOldbwl ( 2012-08-08 12:46:21 +0200 )edit

Once you've installed the extension, how do you access the search dialog in Libre Office?

v4.1.5.3 OSX 10.9.2

Elwood Nose gravatar imageElwood Nose ( 2014-04-07 20:01:54 +0200 )edit

A toolbar with a green binoculars icon is installed or in Menu/Edit/Alt. Find & Rep.

m.a.riosv gravatar imagem.a.riosv ( 2014-04-07 22:42:56 +0200 )edit

I had the same issue keeping me from Liberoffice. Now I can use it instead of XXXX. Hopefully they can add this to the main package!

whale gravatar imagewhale ( 2015-08-07 16:13:42 +0200 )edit
1

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

Pedro gravatar image
edit flag offensive delete link more
0

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

Oldbwl gravatar image

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.

edit flag offensive delete link more
0

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

David gravatar image

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.!)

edit flag offensive delete link more
0

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

ugm6hr gravatar image

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

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

edit flag offensive delete link more

Comments

The line-end character ($) can only be used in isolation and not in combination with other (literal) characters, in the default search / replace facility in v3.5 through v4.2 of LO.

oweng gravatar imageoweng ( 2014-04-20 12:46:47 +0200 )edit
0

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

adaca gravatar image

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....

edit flag offensive delete link more

Comments

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

m.a.riosv gravatar imagem.a.riosv ( 2012-12-05 22:35:11 +0200 )edit

It is not possible to perform a replace over a line-ending, using the default regular expression engine in LO. This engine also only appear to support a basic substitution (i.e., & representing the entire search expression) rather than enumerated capture groups (i.e., \1, \2, etc.)

oweng gravatar imageoweng ( 2014-04-20 12:49:53 +0200 )edit

Question Tools

2 followers

Stats

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

Seen: 26,981 times

Last updated: Dec 05 '12