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

Discuss the word processor

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

Postby takoateli » Wed Aug 10, 2011 6:00 pm

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
takoateli
 
Posts: 5
Joined: Wed Aug 10, 2011 5:37 pm

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

Postby Hagar Delest » Wed Aug 10, 2011 6:09 pm

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.
AOO 4.1.7 on Xubuntu 19.10 and 4.1.5 on Windows 10 (with winPenPack port).
User avatar
Hagar Delest
Moderator
 
Posts: 28681
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

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

Postby takoateli » Wed Aug 10, 2011 6:34 pm

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
takoateli
 
Posts: 5
Joined: Wed Aug 10, 2011 5:37 pm

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

Postby gerard24 » Wed Aug 10, 2011 6:44 pm

Hi,

May be you forgot this step :
(in More options: Format -> bold)
LibreOffice 6.3.4 on Windows 10
gerard24
Volunteer
 
Posts: 953
Joined: Sat Oct 30, 2010 5:12 pm
Location: France

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

Postby takoateli » Wed Aug 10, 2011 6:53 pm

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: 5
Joined: Wed Aug 10, 2011 5:37 pm

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

Postby takoateli » Wed Aug 10, 2011 7:22 pm

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
takoateli
 
Posts: 5
Joined: Wed Aug 10, 2011 5:37 pm


Return to Writer

Who is online

Users browsing this forum: No registered users and 12 guests