[Solved] Find and append in a different font

Discuss the word processor
Post Reply
ksuperjack
Posts: 2
Joined: Sat Jul 15, 2017 11:09 pm

[Solved] Find and append in a different font

Post by ksuperjack »

I would like to append to a found "Search for" text with a different font style without replacing the original text. I know that you can use the Regular expressions (aka.wildcard) to append to found text by using "&" and you can change the "Replace with" format to change the output text, but would like to append to the original text with a different font to distinguish between the two.
e.g.
Find: roses (in Arial)
Replace: & are red (in Times New Roman format)
desired output: roses (in Arial) are red (in Times New Roman)
actual output: rose are red (all in Times New Roman)
Last edited by MrProgrammer on Sat Nov 21, 2020 2:44 am, edited 1 time in total.
Reason: Tagged ✓ [Solved]
Open Office 4.1.3 Windows10
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Find and Append-not Replace

Post by RusselB »

A quick look at the options available implies to me that you can specify the Font in the Search by selecting the Format button while the cursor is in the Search part of the Find and Replace Dialog.
The same button is available when the cursor is in the Replace portion of the dialog.
The format button is in the More Options section, which you seem to be aware of, as that is where the switch to allow Regular Expressions in the search is located.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
FJCC
Moderator
Posts: 9277
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Find and Append-not Replace

Post by FJCC »

You can find the character that follows the word "bode" with this in the Search For box

Code: Select all

(?<=bode).
In the Replace With you can then insert text, say the word HERE, between bode and the found character with

Code: Select all

HERE&
The HERE can be formatted and will not affect the format of the "bode". This will affect the formatting of the character following bode. If that is a space, then I expect you can tolerate that. Otherwise. you can make a second search for the text following whatever you inserted and reformat it.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Find and Append-not Replace

Post by acknak »

I'm not sure I understand what you're trying to do, but as far as I know it's not possible for the replacement text to be formatted in any particular way.

If you've worked out the find & replace to get the text you want, "Replace All" should leave you with all of the replacements selected. At that point, you can "Find All" for the appended replacement text string, with the "Current selection only" option ON, and get only the appended text selected. Then you can apply whatever formatting you want as a separate action (nothing to do with Find & Replace).
 Edit: PS: 
Oops. For some reason, when I tried this at first, "Replace All" did leave all of the replacements selected; trying it again, I see that it doesn't. I'm not sure why that's behaving differently now.

In that case, you may have to make the appended text unique in some way, for example, replace with &{abc}, the do a separate search for the bracketed text, apply the formatting, then find/replace to remove the brackets.
 Edit: PPS: 
OIC. If you do "Replace All" with the Format specified (say, with a specific font), then "Find All" leaves the replacements selected. Without the format option, it doesn't.
AOO4/LO5 • Linux • Fedora 23
ksuperjack
Posts: 2
Joined: Sat Jul 15, 2017 11:09 pm

[SOLVED] Re: Find and Append-not Replace

Post by ksuperjack »

Thanks for the suggestions however none worked for me.
It seams that you can add text by:
Search for: \<(original text) [in original Format]
Replace with: additional text& [with new Format]
Always replaces: original text additional text [all in new Format]

If somebody tests and figures out a way to add text in a new format without changing the original text's format, please let me know
FJCC wrote:You can find the character that follows the word "bode" with this in the Search For box

Code: Select all

(?<=bode).
In the Replace With you can then insert text, say the word HERE, between bode and the found character with

Code: Select all

HERE&
The HERE can be formatted and will not affect the format of the "bode". This will affect the formatting of the character following bode. If that is a space, then I expect you can tolerate that. Otherwise. you can make a second search for the text following whatever you inserted and reformat it.
Last edited by ksuperjack on Sun Jan 24, 2021 4:23 pm, edited 1 time in total.
User avatar
MrProgrammer
Moderator
Posts: 4907
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Find and Append-not Replace

Post by MrProgrammer »

Hi, and welcome to the forum.
ksuperjack wrote:Find: roses (in Arial)
Replace: & are red (in Times New Roman format)
desired output: roses (in Arial) are red (in Times New Roman)
Let Ω represent a character or characters which will not otherwise appear in your text.
File → New → Text document → type the two letters DT then press F3. (This creates a test paragraph.)
Edit → Find & Replace
Search for: steps → Replace with: & Ω → More options → Regular expressions → Replace All
Search for: Ω → Replace with: *** → Format → Size=16 → OK → Replace All
Screen Shot 2017-07-23 at 21.10.45 .jpg
If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
Post Reply