[Solved] How-search and bracket every italized word
-
- Posts: 88
- Joined: Mon Dec 24, 2007 7:38 pm
[Solved] How-search and bracket every italized word
Hi, i much appreciated OOo, and am using 3.1.1. I would like to search search and replace to find every instance of italicized word in a large document, and then place brackets around it. I can find a specific italicized word by using the formatting option, but i just want to automatically find everyone, by using a wildcard perhaps. Any suggestions? Thanks
Last edited by TheGurkha on Tue Oct 13, 2009 11:53 pm, edited 1 time in total.
Reason: Tagged Solved.
Reason: Tagged Solved.
Windows 11 Pro, Ryzen 3 3200G CPU; 64GB RAM
Grace and peace thru Jesus the Lord. peacebyjesus.net (pages created in Open office)
Grace and peace thru Jesus the Lord. peacebyjesus.net (pages created in Open office)
Re: How-search and bracket every italized word
Within the search menu, select "More options" and check "Regular expressions" (regular expressions are a "generalization" of wildcards). On "Search" write
(.*)
and select the Italics attribute as before. On "Replace with" write:
[$1]
Now click "Replace all".
(.*)
and select the Italics attribute as before. On "Replace with" write:
[$1]
Now click "Replace all".
There are two types of people: those who believe that there are two types of people and those who do not.
openSUSE Leap with KDE Plasma / LibreOffice
openSUSE Leap with KDE Plasma / LibreOffice
-
- Posts: 88
- Joined: Mon Dec 24, 2007 7:38 pm
Re: How-search and bracket every italized word
Well, may God bless you! I am amazed how some people know these things. One small adjustment though is that it places a space [is ] after the last letter, and also removes the space between the next word ([is ]no). I can fix the latter by placing a space after the [$1] , but the other space remains. BTW, is there a way to restrict the italicized characters to letters, excluding words? Almost there.
Windows 11 Pro, Ryzen 3 3200G CPU; 64GB RAM
Grace and peace thru Jesus the Lord. peacebyjesus.net (pages created in Open office)
Grace and peace thru Jesus the Lord. peacebyjesus.net (pages created in Open office)
Re: How-search and bracket every italized word
Obviously these spaces are italicized, too.
You can either search all white space and remove the format before your search,
or search for [:alpha:]* or [:alnum:]* instead of .*
or search for word boundaries, e.g. \<.*\>
or with non/capturing groups and more explicite back referencing for the replacement.
But I wouldn't recommend the latter to regex noobs, as long as you can do it without.
You can either search all white space and remove the format before your search,
or search for [:alpha:]* or [:alnum:]* instead of .*
or search for word boundaries, e.g. \<.*\>
or with non/capturing groups and more explicite back referencing for the replacement.
But I wouldn't recommend the latter to regex noobs, as long as you can do it without.
OOo 3.2.1 on ubuntu 10.4, MsWXP, MsW2k
-
- Posts: 88
- Joined: Mon Dec 24, 2007 7:38 pm
Re: How-search and bracket every italized word
Well, searching for [:alnum:]* (regular expressions, with format>italics) and replacing italicized words [$1] results in every italicized words or numbers being replaced with just, [] - w/out the word in it. Searching \<.*\> with [$1] ignores spaces but replaces words and numbers with []. Searching [:alpha:]*with [$1] does ignore the numbers but still replaces the italicized words with just []. I found you also have to be careful not to have spaces before or after the search term.
My work around is to search (.*), and replace with [$1], and then search for ] (with a space before it) and replace it with ] (no space). The numbers i can also deal with. As for regex noobs, that probably fits me, whatever it means.
My work around is to search (.*), and replace with [$1], and then search for ] (with a space before it) and replace it with ] (no space). The numbers i can also deal with. As for regex noobs, that probably fits me, whatever it means.
Windows 11 Pro, Ryzen 3 3200G CPU; 64GB RAM
Grace and peace thru Jesus the Lord. peacebyjesus.net (pages created in Open office)
Grace and peace thru Jesus the Lord. peacebyjesus.net (pages created in Open office)
Re: How-search and bracket every italized word
The parentheses are important: they direct Writer to save whatever matches between them so it can be recalled by "$1" in the replacement.Well, searching for [:alnum:]* ... and replacing italicized words [$1] results in every italicized words or numbers being replaced with just, []
Try Search for: ([:alnum:]*)
AOO4/LO5 • Linux • Fedora 23
-
- Posts: 88
- Joined: Mon Dec 24, 2007 7:38 pm
Re: How-search and bracket every italized word
I see! I thought i had tried that, but search ([:alpha:]*) and replace with [$1] changes all the italicized words perfectly! Using ([:alnum:]*) does numbers also. Last question: any way to change two italicized words together (it is) ? As of now it places both in individual brackets. Thanks.
Windows 11 Pro, Ryzen 3 3200G CPU; 64GB RAM
Grace and peace thru Jesus the Lord. peacebyjesus.net (pages created in Open office)
Grace and peace thru Jesus the Lord. peacebyjesus.net (pages created in Open office)
Re: How-search and bracket every italized word
Oh well, I should've been more explicite.PeaceByJesus wrote:... [:alnum:]* ... results in ... being replaced with just, []
referred totn@BeWo wrote:... [:alpha:]* or [:alnum:]* instead of .*
and was meant to replace the content of the brackets rather than the whole group - sorry for the inconvenience.RGB wrote:... (.*)
As for spaces (single spaces? arbitrary number of occurrencies - i.e. n words/expressions with n-1 spaces between them?), you might try
([^ ]+([ ]?[^ ]+)+)
[$1]
Different from the POSIX classes, this will also match words containing ' like in "We'll see", - like in "dead-end" and other in-italics-punctuation.
It will break up groups seperated by 2 or more spaces.
If it's still not what you need, it should give you a good start for further testing.
OOo 3.2.1 on ubuntu 10.4, MsWXP, MsW2k
-
- Posts: 88
- Joined: Mon Dec 24, 2007 7:38 pm
Re: [Solved] How-search and bracket every italized word
Better all the time. ([^ ]+([ ]?[^ ]+)+) with [$1] (using regular expressions, with format>italics) places brackets around all the italicized words perfectly. And it brackets 2 or more italicized words together, not individually. It does not differentiate btwn words and numbers, but that's not a real problem. Thanks. As for cPOSIX classes, that's beyond me!
Windows 11 Pro, Ryzen 3 3200G CPU; 64GB RAM
Grace and peace thru Jesus the Lord. peacebyjesus.net (pages created in Open office)
Grace and peace thru Jesus the Lord. peacebyjesus.net (pages created in Open office)