RegEx - how to replace a carriage return

Discuss the word processor

RegEx - how to replace a carriage return

Postby franc » Tue May 01, 2018 9:28 pm

Hallo

I am trying to replace with a Regular Expression some numbers with carriage return (also called paragraph breaks) to nothing but it aint working.
This is examplarily my text:
Blabla
1
blabla
blablablabla
2
blabla blabla
12
blabla
13
basdaf
asdfasd
14
asdfa

where I want to eliminate the numbers (these were page numbers, hardcoded ones) but also the carriage returns (such ones done with Return without Space).
I could easily find and replace with nothing the numbers, no problem, but then I have left some empty lines.
In normal RegEx I would go for the hex value, e.g.:
Search with Regex:
Code: Select all   Expand viewCollapse view
\x0A

and combine it with the numbers, e.g.
Code: Select all   Expand viewCollapse view
\x0A\d{1,2}

but this (\x0A) doesnt find the carriage returns on my Mac OS 10.11.6 with OO 4.1.5

So neither are working \n nor \x00A nor \x000A nor \x0D\x0A - I tried a lot.

I found in some post the $ (which is in normal RegEx just the line end, without any length!) but this is not helping, because I can not eliminate the carriage return, I can just find a line's end.

So how can I find and replace the real carriage return character with regex on Mac OS 10.11.6 and OO 4.1.5?

The digits I easily can find, but only not the carriage return.
The line break (with Space+Retrurn) I can find with \n

Thanks.

frank

PS.: I asked that in a german openoffice forum before and got there the hint to ask here.
OpenOffice 3.3
franc
 
Posts: 21
Joined: Sat Oct 08, 2011 2:12 pm

Re: RegEx - how to replace a carriage return

Postby Zizi64 » Tue May 01, 2018 9:38 pm

The digits I easily can find, but only not the carriage return.
The line break (with Space+Retrurn) I can find with \n

You can find and replace the CR signs with the AltSearch extension.
https://extensions.libreoffice.org/exte ... for-writer
https://extensions.openoffice.org/en/pr ... -altsearch

But it not a good idea to replace ALL of the CR-s from a document, because the paragraphs have a character number limit...
Last edited by Zizi64 on Wed May 02, 2018 6:42 am, edited 2 times in total.
Tibor Kovacs, Hungary; LO4.4.7, LO6.1.1 on Win7x64Prof.
PortableApps, winPenPack: LO3.3.0-LO6.1.2 and AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 7357
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: RegEx - how to replace a carriage return

Postby FJCC » Wed May 02, 2018 2:16 am

Does it work to eliminate the numbers and then search for empty paragraphs with ^$
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6803
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: RegEx - how to replace a carriage return

Postby franc » Wed May 02, 2018 10:04 am

Zizi64 wrote:...
You can find and replace the CR signs with the AltSearch extension.
...

That is not working on my mac (on PC no problems), see attached Screenshot.
Zizi64 wrote:...
But it not a good idea to replace ALL of the CR-s from a document, because the paragraphs have a character number limit...

No problem to replace two CRs with just one, my problem is, that there are one too much, so I have an empty line.
Attachments
Bildschirmfoto 2018-05-02 um 10.03.04.png
AltSearch Dialog
OpenOffice 3.3
franc
 
Posts: 21
Joined: Sat Oct 08, 2011 2:12 pm

Re: RegEx - how to replace a carriage return

Postby Villeroy » Wed May 02, 2018 10:36 am

^[[:digit:]]+$ finds paragraphs that consist of digits.
Replace them with nothing and then replace the empty paragraphs ^$ with nothing.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 25827
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: RegEx - how to replace a carriage return

Postby franc » Wed May 02, 2018 10:47 am

Thank.
But this is not possible as solution, because there are other empty paragraphs which are indeed wanted.
I need to replace in one go.
OpenOffice 3.3
franc
 
Posts: 21
Joined: Sat Oct 08, 2011 2:12 pm

Re: RegEx - how to replace a carriage return

Postby Villeroy » Wed May 02, 2018 12:18 pm

Apply correct spacings between paragraphs instead of blank paragraphs?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 25827
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: RegEx - how to replace a carriage return

Postby franc » Wed May 02, 2018 5:26 pm

Yes
OpenOffice 3.3
franc
 
Posts: 21
Joined: Sat Oct 08, 2011 2:12 pm

Re: RegEx - how to replace a carriage return

Postby Villeroy » Wed May 02, 2018 7:46 pm

Well, then remove all blank paragraphs and apply paragraph styles. Style "Text Body" for instance, includes some extra spacing.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 25827
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Writer

Who is online

Users browsing this forum: Google [Bot], robleyd and 19 guests