[Solved] Find the first non-bold char in a paragraph

Discuss the word processor
Post Reply
takoateli
Posts: 8
Joined: Wed Aug 10, 2011 5:37 pm

[Solved] Find the first non-bold char in a paragraph

Post by takoateli »

I'm hoping there's a hard core regex search user on the forum who can point me in the right direction.

I'm trying to take a OOWriter doc which is a dictionary and convert it to a .csv delimited file. The file has the following format. The first word or words of each paragraph which is the term being defined in the dictionary and is in bold, then the definition follows in normal (non-bold) text.

I want to insert a delimiter character between the term and the definition.

What I need is a regex which will find the first non-bold word or character in a paragraph so I can insert a delimiter character just before it. Is that doable?

Thanks for any replies.

I've spent a great deal of time searching and reading. I think I'm on the right trail but I'm not getting it on my own. If anyone could steer me in the right direction it would be greatly appreciated!

Greg
Last edited by Hagar Delest on Wed Aug 10, 2011 8:19 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 3.3.0 on Mac OS X 10.7
User avatar
Hagar Delest
Moderator
Posts: 32664
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Regex search - find the first non-bold char in a paragra

Post by Hagar Delest »

Hi and welcome to the forum!

What seems to work (note that I add the coma after the bold word instead of before the first non bold word but I guess it's the same for the export):
- Search for: .* (in More options: Format -> bold)
- Replace with: &,
In the More options, check Regular expressions.
Then Find All and Replace all.
Replace.png
Please add '[Solved]' at the beginning of your first post title (edit button) if your issue has been fixed.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
takoateli
Posts: 8
Joined: Wed Aug 10, 2011 5:37 pm

Re: Regex search - find the first non-bold char in a paragra

Post by takoateli »

Hagar de l'Est wrote:Hi and welcome to the forum!

What seems to work (note that I add the coma after the bold word instead of before the first non bold word but I guess it's the same for the export):
- Search for: .* (in More options: Format -> bold)
- Replace with: &,
In the More options, check Regular expressions.
Then Find All and Replace all.
Replace.png
Please add '[Solved]' at the beginning of your first post title (edit button) if your issue has been fixed.
Wow that's really doing something different for me. Searching for .* is highlighting the whole paragraph and if I do a replace it's bolding the whole thing! Very different behavior from what you got. What am I doing wrong?

Greg
OpenOffice 3.3.0 on Mac OS X 10.7
gerard24
Volunteer
Posts: 958
Joined: Sat Oct 30, 2010 5:12 pm
Location: France

Re: Regex search - find the first non-bold char in a paragra

Post by gerard24 »

Hi,

May be you forgot this step :
(in More options: Format -> bold)
LibreOffice 6.4.5 on Windows 10
takoateli
Posts: 8
Joined: Wed Aug 10, 2011 5:37 pm

Re: Regex search - find the first non-bold char in a paragra

Post by takoateli »

gerard24 wrote:Hi,

May be you forgot this step :
(in More options: Format -> bold)
Doh! Thanks! That works almost as needed. We're getting close but there's a problem, and that is in the description there also are words that are also in bold. The regex you suggested is finding them too. That's why the regex has to match only the bold at the start of the paragraph. Is there any way to do that?

Thanks!
Greg
OpenOffice 3.3.0 on Mac OS X 10.7
takoateli
Posts: 8
Joined: Wed Aug 10, 2011 5:37 pm

Re: Regex search - find the first non-bold char in a paragra

Post by takoateli »

takoateli wrote:
gerard24 wrote:Hi,

May be you forgot this step :
(in More options: Format -> bold)
Doh! Thanks! That works almost as needed. We're getting close but there's a problem, and that is in the description there also are words that are also in bold. The regex you suggested is finding them too. That's why the regex has to match only the bold at the start of the paragraph. Is there any way to do that?

Thanks!
Greg
It looks like changing the input string from .* to ^.* did the trick.

Thanks for getting me started!

Greg
OpenOffice 3.3.0 on Mac OS X 10.7
Post Reply