[Solved] Regular expression for paragraph start

Discuss the word processor
Post Reply
jacksparrowjive
Posts: 8
Joined: Sun Apr 11, 2021 1:30 am

[Solved] Regular expression for paragraph start

Post by jacksparrowjive »

I need to add a specific notation to the beginning of every new paragraph(the exact same one for every paragraph). Is there a regular expression or I can search for representing a new paragraph, that I can then insert my notation to be added? Thanks!
Last edited by MrProgrammer on Fri Mar 08, 2024 4:00 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
OpenOffice 4.1.6 / WIN10
User avatar
robleyd
Moderator
Posts: 5263
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Regular expression for start of new paragraph?

Post by robleyd »

From the HELP for regular expressions:
^
Only finds the search term if the term is at the beginning of a paragraph. Special objects such as empty fields or character-anchored frames, at the beginning of a paragraph are ignored. Example: "^Peter".
Note; this will also find text in footers and headers!

As you want to add something to the beginning of existing paragraphs your Find string would be

Code: Select all

(^.)
and your Replace string would be

Code: Select all

a specific notation $1
Obviously, replace a specific notation with the actual text required
Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.8.3.2; SlackBuild for 24.8.3 by Eric Hameleers
---------------------
Roses are Red, Violets are Blue
Unexpected '{' on line 32
.
JeJe
Volunteer
Posts: 2922
Joined: Wed Mar 09, 2016 2:40 pm

Re: Regular expression for start of new paragraph?

Post by JeJe »

If you mean an empty paragraph, find with,
^$
For the replace for an empty paragraph, whatever you want followed by \n
Whatever\n

A different method than already suggested for a non-empty paragraph is
.*
For the replace, add whatever to the front by following with & (& keeps the original text)
whatever&
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply