First time here? Check out the FAQ!
asked 2012-08-08 06:13:07 +0200Oldbwl
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
answered 2012-08-08 10:28:39 +0200mariosv
I think this extension can help:
answered 2012-08-08 07:17:35 +0200Pedro
Did you enable the Regular Expressions option?
answered 2012-12-01 11:58:27 +0200David
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.!)
answered 2012-12-01 10:37:59 +0200ugm6hr
If you enable (tick) "Regular Expressions" in the find & replace box, the $ sign indicates a paragraph mark for searching.
So: Search: ", $" Replace: ", "
answered 2012-08-08 08:08:56 +0200Oldbwl
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.
answered 2012-12-05 15:58:59 +0200adaca
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....
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!
Asked: 2012-08-08 06:13:07 +0200
Seen: 2,521 times
Last updated: Dec 05 '12