Welcome to NeoOffice developer notes and announcements
NeoOffice
Developer notes and announcements
 
 

This website is an archive and is no longer active
NeoOffice announcements have moved to the NeoOffice News website


Support
· Forums
· NeoOffice Support
· NeoWiki


Announcements
· Twitter @NeoOffice


Downloads
· Download NeoOffice


  
NeoOffice :: View topic - Find & Replace underscores with italic?
Find & Replace underscores with italic?
 
   NeoOffice Forum Index -> NeoOffice Releases
View previous topic :: View next topic  
Author Message
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Mon Dec 27, 2010 5:17 pm    Post subject: Find & Replace underscores with italic?

I've received a long, long plaintext which (for reasons to do with unreason) the author has marked up with _underscore characters_ when the text between them should be in italics.

I've managed to replace the opening character with a ± and the closing one with a § (that was some fun)'

Is there a way to get the F&R to replace instances of these pairs of characters with italic/end-of-italic?
Back to top
pluby
The Architect
The Architect


Joined: Jun 16, 2003
Posts: 11949

PostPosted: Mon Dec 27, 2010 6:31 pm    Post subject:

Now that you have replaced beginning "_" characters with "±" and ending "_" characters with "§", you should be able to do this using the following steps. The tricky part for me was figuring out what to put in the "Search for" field so that multiple occurrences of these characters in a single paragraph are handled properly.

1. Position the cursor at the very beginning of your document and open the Find and Replace dialog.

2. Put the following in the "Search for" field:

Code:
±([^§]*)§


3. Put the following in the "Replace with" field:

Code:
$1


4. Press the "More Options button and check the "Regular expressions" checkbox.

5. Put the cursor in the "Replace with" field and press the "Format" button. In the dialog that appears, click on the "Font" tab, select "Italic" from the "Typeface" column, and press the "OK" button.

6. Make sure that the "Search backwards" checkbox is unchecked and then press the "Replace" button. If you are confident that the "Replace" button is doing what you want, then you can press the "Replace All" button.

Does that work for you?

Patrick
Back to top
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Tue Dec 28, 2010 2:00 am    Post subject:

Hi, thanks, I'd already got a response from floris_v over at the OOo forum, which led me to the following similar solution:

• perform a Find All on ±[^§]*
• close the Find & Replace box
• cmd-I to make all selected text italics
• use Find & Replace to delete all ± & §

...but I just tried yours too (for educational purposes) and it works fine, with less steps.

Many thanks, I'll post your solution over there Smile.
Back to top
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: Tue Dec 28, 2010 3:35 pm    Post subject:

We should add this to the Using Find and Replace page on the wiki.

I missed the replies somehow and just worked this out myself based on the info in the wiki and a tiny bit of the Help file (ending up with Patrick's steps, which I think are saner/safer than the other ones yoxi got from OOo), but setting up a concrete example in the wiki would be much more useful for future users than having to piece it together themselves Wink

Note: for the unmodified _original file_, you'd want to use
Code:
_([^_]+)_
in the "Search for:" field.

Smokey

_________________
"[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
Back to top
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Tue Dec 28, 2010 4:09 pm    Post subject:

That's just sexy Wink - thanks. This is likely to happen again, so it's good not to have to do the extra layer of conversion. By the way, I ended up using Patrick's instead anyway!
Back to top
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: Tue Dec 28, 2010 4:24 pm    Post subject:

And now in the wiki: http://neowiki.neooffice.org/index.php/Using_Find_and_Replace#Changing_the_style_of_all_occurrences_of_a_string

Glad to be able to help, and sorry I couldn't get to it before Patrick or the other answer; I've been swamped for a while now Sad

Smokey

_________________
"[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
Back to top
Display posts from previous:   
   NeoOffice Forum Index -> NeoOffice Releases All times are GMT - 7 Hours
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © Planamesa Inc.
NeoOffice is a registered trademark of Planamesa Inc. and may not be used without permission.
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.