[Solved] RegEx: Finding all Words in Parenthesis

Discuss the word processor
Post Reply
User avatar
Bhikkhu Pesala
Posts: 1253
Joined: Mon Oct 08, 2007 1:27 am

[Solved] RegEx: Finding all Words in Parenthesis

Post by Bhikkhu Pesala »

I want to find and select any words or phrases in parentheses, so that I can italicize them. If possible, I also want to select any punctuation after the closing parenthesis.

For example, I want to italicise like this:

Craving arises from the feeling (vedanā) produced by contact (phassa), which in turn depends on the six sense-bases (saḷāyatana) such as the eye and visual form. Sense-bases are the product of mind and matter (nāmarūpa), which depend on consciousness (viññāṇa).
Last edited by Bhikkhu Pesala on Tue Jan 15, 2008 11:32 pm, edited 1 time in total.
Idiot Compassion
LibreOffice 6.0.4 on Windows 10
User avatar
floris v
Volunteer
Posts: 4638
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: RegEx: Finding all words in Parenthesis

Post by floris v »

\(([^ ])+\) will do, if you don't want spaces in parentheses. If you search for any series of characters in () you get into problems with OOo being greedy, so it selects too much.
LibreOffice 25.8.4.2 on Ubuntu Linux
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
User avatar
Bhikkhu Pesala
Posts: 1253
Joined: Mon Oct 08, 2007 1:27 am

Re: RegEx: Finding all words in Parenthesis

Post by Bhikkhu Pesala »

Thanks, that did it. I did a separate search for \(([^ ])+\), and \(([^ ])+\); to find the parentheses followed by punctuation. ). is not too bad, but ); doesn't look too good if the ; is not italicized.
Idiot Compassion
LibreOffice 6.0.4 on Windows 10
User avatar
floris v
Volunteer
Posts: 4638
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: [Solved] RegEx: Finding all Words in Parenthesis

Post by floris v »

I actually thought you were pulling my leg. ;) And I don't like the look of parentheses in italics. Btw, did you know that some people actually claim that (some text) doesn't mean the same thing as (some text)?
LibreOffice 25.8.4.2 on Ubuntu Linux
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: [Solved] RegEx: Finding all Words in Parenthesis

Post by acknak »

Another approach:

Code: Select all

\([^)]*\)[^ ]?
AOO4/LO5 • Linux • Fedora 23
Post Reply