| View previous topic :: View next topic |
| Author |
Message |
dzurn General User

Joined: 12 Jul 2007 Posts: 9
|
Posted: Thu Jul 12, 2007 1:45 pm Post subject: How to search for text and make it bold |
|
|
I have some text I want to search for in Writer. It's of the form "Item: 21-9999-99". The 9's will always change, so my regular expression in the search box was this:
Item: 21-[:digit:]*[:digit:]*[:digit:]*[:digit:]*-[:digit:]*[:digit:]*
The replace box is empty with the format set to Bold. However when the searches replace the text, instead of bolding my text it just deletes it! (The empty space is bold, however)
(Question 1): Can the OpenOffice Find and Replace dialog keep the text it found and just add the attribute?
(Q1.5): Can I replace but not skip to the next found item? I need to check that the replacement worked as expected before continuing.
(Q2): Are there any backreferences that work in the "replace" box when searching for RegExes?
I'd settle for finding the text and using a named style, but (Q3): I can't find a way to assign the style in the Replace box. (I don't need to replace all of one style with another, I need to conditionally change to the style).
Last, (Q4): Can I search for page breaks? View Paragraphs can't show them either.
Word does not have these issues. I spend 5% of my working day finding arbitrary text and assigning attributes to them, but can I do this in OO?
Unfortunately OO seems fixated on Regular Expressions, which look at text only one line (paragraph) at a time. However real-world editing is much more likely to require spanning several lines and change text attributes based on various conditions.
Lots of questions in this thread, I guess.
Thanks
[EDIT: I guess I should add that I'm using NeoOffice on a Mac, but the search issues don't seem to change] |
|
| Back to top |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
Posted: Thu Jul 12, 2007 2:30 pm Post subject: Re: How to search for text and make it bold |
|
|
| dzurn wrote: |
(Question 1): Can the OpenOffice Find and Replace dialog keep the text it found and just add the attribute? |
Put & in the Replace box
| dzurn wrote: |
(Q2): Are there any backreferences that work in the "replace" box when searching for RegExes? |
I don't think so. You can however use Python with OpenOffice when you can replace with backreferences.
| dzurn wrote: |
Unfortunately OO seems fixated on Regular Expressions, which look at text only one line (paragraph) at a time. However real-world editing is much more likely to require spanning several lines and change text attributes based on various conditions. |
I guess one needs to decide what one expects of a text editor and what one expects of a word-processor. |
|
| Back to top |
|
 |
dzurn General User

Joined: 12 Jul 2007 Posts: 9
|
Posted: Thu Jul 12, 2007 3:35 pm Post subject: |
|
|
Thanks for the "&" hint. That did the trick!
Darryl |
|
| Back to top |
|
 |
acknak Moderator


Joined: 13 Aug 2004 Posts: 4295 Location: ~ 40°N,75°W
|
Posted: Thu Jul 12, 2007 5:21 pm Post subject: |
|
|
| Quote: | | (Q1.5): Can I replace but not skip to the next found item? I need to check that the replacement worked as expected before continuing. |
Sure. Just click Find (moves to the next match and highlights it), then Replace (does the replacement and moves on to the next match and highlights it). Just keep clicking Replace to process each match in turn. Click Find to move on without doing the replacement.
| Quote: | | (Q3): I can't find a way to assign the style in the Replace box. |
Really? I usually just click Find All (selects all the matches), then use the Writer toolbar or the Stylist to apply a style to the selected text. OOo's Find & Replace dialog gains a lot of flexibility by being "non-modal". You don't have to do everything from within the dialog.
| Quote: | | (Q4): Can I search for page breaks? View Paragraphs can't show them either. |
No, and correct.
Page breaks are shown by a nearly-invisible line at the top margin of the page started by the break. You can change the color of the line to something more visible but it doesn't help much. A really poor design but waay down on the priority list.
| Quote: | | Unfortunately OO seems fixated on Regular Expressions, which look at text only one line (paragraph) at a time. However real-world editing is much more likely to require spanning several lines and change text attributes based on various conditions. |
OOo's regular expressions are poor in several respects, but I've found very little that I needed to do and couldn't. I really don't find too many tasks that need to span paragraphs (lines are not a problem), except when cleaning up plain text to be imported into Writer. In that case, I just use a "real" text editor to do the cleanup. |
|
| Back to top |
|
 |
dzurn General User

Joined: 12 Jul 2007 Posts: 9
|
Posted: Thu Jul 12, 2007 6:09 pm Post subject: |
|
|
| acknak wrote: | | Quote: | | (Q1.5): Can I replace but not skip to the next found item? I need to check that the replacement worked as expected before continuing. |
Sure. Just click Find (moves to the next match and highlights it), then Replace (does the replacement and moves on to the next match and highlights it). Just keep clicking Replace to process each match in turn. Click Find to move on without doing the replacement.
|
What I wanted was to be able to do a "replace" but keep the selection where it is. Word doesn't do that either, to be fair, but I was working on a document with one change per page that I wanted to see before moving on. Not a big deal.
| Quote: |
| Quote: | | (Q3): I can't find a way to assign the style in the Replace box. |
Really? I usually just click Find All (selects all the matches), then use the Writer toolbar or the Stylist to apply a style to the selected text. OOo's Find & Replace dialog gains a lot of flexibility by being "non-modal". You don't have to do everything from within the dialog.
|
That's good to know. I haven't tried the "Find All" button, I'll give it a whirl.
| Quote: |
| Quote: | | (Q4): Can I search for page breaks? View Paragraphs can't show them either. |
No, and correct.
Page breaks are shown by a nearly-invisible line at the top margin of the page started by the break. You can change the color of the line to something more visible but it doesn't help much. A really poor design but waay down on the priority list.
|
Thanks for the info, I'm glad I'm not just missing some obvious setting or technique.
| Quote: |
| Quote: | | Unfortunately OO seems fixated on Regular Expressions, which look at text only one line (paragraph) at a time. However real-world editing is much more likely to require spanning several lines and change text attributes based on various conditions. |
OOo's regular expressions are poor in several respects, but I've found very little that I needed to do and couldn't. I really don't find too many tasks that need to span paragraphs (lines are not a problem), except when cleaning up plain text to be imported into Writer. In that case, I just use a "real" text editor to do the cleanup. |
Agreed. I just have to get more used to how OO uses RegEx'es ("Find \n and replace with \n"? Eh?). It'd be Real Nice™ to have access to backreferences in the replacement box, though.
With these answers I was able to get through the day's challenge pretty well. I'm sure I'll start to use them a lot more.
Darryl |
|
| Back to top |
|
 |
acknak Moderator


Joined: 13 Aug 2004 Posts: 4295 Location: ~ 40°N,75°W
|
Posted: Thu Jul 12, 2007 6:42 pm Post subject: |
|
|
| Quote: | | I was working on a document with one change per page that I wanted to see before moving on. |
Oh, duh. I missed that completely and I've wanted that many times myself. No decent way that I've found. It would be nice to have both a "Replace" and a "Replace and Find" button. |
|
| Back to top |
|
 |
BillP Super User

Joined: 07 Jan 2006 Posts: 2702
|
Posted: Thu Jul 12, 2007 6:51 pm Post subject: |
|
|
| dzurn wrote: | | It'd be Real Nice™ to have access to backreferences in the replacement box, though.l |
This issue was submitted 4 years ago. You can register and vote for it here:
http://qa.openoffice.org/issues/show_bug.cgi?id=15666 |
|
| Back to top |
|
 |
AndrewZ Moderator


Joined: 21 Jun 2004 Posts: 4140 Location: Colorado, USA
|
|
| Back to top |
|
 |
|