Recherche et remplacement de texte et de formatage

From Apache OpenOffice Wiki
< FR‎ | Documentation‎ | Writer Guide
Revision as of 14:33, 12 April 2009 by Sgauti (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



Lorsque l'on recherche certains mots dans un essaie en comportant 3 000, il est inefficace d'examiner chaque mot manuellement. Writer a une fonction de recherche et de remplacement qui automatise le processus de recherche dans le texte à l'intérieur du document.

En plus de trouver et de remplacer des mots et des phrases, vous pouvez :

  • Utiliser les caractères génériques et les expressions régulière pour affiner la recherche.
  • Rechercher et remplacer des formatages spécifiques.
  • Rechercher et remplacer des styles de paragraphe.

Pour afficher la boîte de dialogue Rechercher & remplacer, utilisez le raccourci clavier Ctrl+F ou sélectionnez Édition > Rechercher & remplacer.

  1. Saisissez le texte que vous souhaitez trouver dans le champ Rechercher.
  2. Pour remplacer le texte avec un texte différent, saisissez le nouveau texte dans le champ Remplacer par.
  3. Vous pouvez sélectionner des options telles que respecter la casse, mots entiers uniquement ou effectuer une recherche de similarité (voir ci-dessous pour d'autres choix).
  4. Lorsque vous avez défini la recherche, cliquez sur Rechercher. Pour remplacer le texte, cliquez sur Remplacer à la place.
La boîte de dialogue Rechercher & Remplacer

Template:Documentation/Tip

Documentation caution.png Utilisez Tout remplacer avec précautions ; vous pourriez vous retrouver avec des erreurs hilarantes (et plutôt embarassantes). Une erreur avec Tout remplacer peut nécessiter une recherche manuelle, mot par mot pour la corriger si non découverte à temps pour l'annuler.

Use wildcards (regular expressions)

Wildcards (also known as regular expressions) are combinations of characters that instruct OOo how to search for something. Regular expressions are very powerful but not very intuitive. They can save time and effort by combining multiple finds into one.

Table 1 shows a few of the regular expressions used by OOo.

Template:Documentation/Tip

Template:Documentation/Note

To use wildcards and regular expressions when searching and replacing:

  1. On the Find & Replace dialog box, click More Options to see more choices. On this expanded dialog box, select the Regular expressions option.
  2. Type the search text, including the wildcards, in the Search for box and the replacement text (if any) in the Replace with box. Not all regular expressions work as replacement characters; the line break (\n) is one that does work.
  3. Click Find, Find All, Replace, or Replace All (not recommended).
Expanded Find & Replace dialog box.

Table 1. Examples of search wildcards (regular expressions)

To find Use this expression Examples and comments
Any single character . b.d finds bad, bud, bid, and bed.
Characters at the beginning of a paragraph ^chars ^term
Characters at the end of a paragraph chars$ term.$
One of the specified characters [xyz] b[iu]n finds bin and bun.
Any single character in this range [x-y] [r-t]eed finds reed, seed, and teed; ranges must be in alphabetically ascending order.
Any single character except the characters inside the brackets [^x] p[^a]st finds post and pest, but not past.
The beginning of a word \<start \<log finds logbook and logistics, but not catalog.
The end of a word end\> log\> finds catalog, but not logistics.
A paragraph marker $ Does not work as a replacement character. Use \n instead.
An empty paragraph ^$
An tab character \t
A line break \n Finds a line break that was inserted with Shift+Enter. When used as a replacement character, it inserts a paragraph marker.

Find and replace specific formatting

A very powerful use of Find & Replace takes advantage of the format option. For example, you might want to replace underlined words with italics.

On the Find & Replace dialog box with More Options displayed:

  1. To search for text with specific formatting, enter the text in the Search for box. To search for specific formatting only, delete any text in the Search for box.
  2. Click Format to display the Text Format (Search) dialog box. The tabs on this dialog box are similar to those on the Paragraph format and Paragraph Style dialog boxes. Choose the formats you want to search for and then click OK. The names of selected formats appear under the Search for box. For example, you might search for all text in 14-point bold Helvetica.
  3. To replace text, enter the replacement text in the Replace with box.
    To search for specific text with specific formatting (for example, the word hello in bold), specify the formatting, put the text in the Search for box and leave the Replace with box blank.>br />To remove specific character formatting, click Format, select the Font tab, then select the opposite format (for example, No Bold). The No Format button on the Find & Replace dialog box clears all previously selected formats.
  4. Click Find, Find All, Replace, or Replace All.

Template:Documentation/Tip

Find and replace paragraph styles

If you combine material from several sources, you may discover that lots of unwanted paragraph styles have suddenly shown up in your document. To quickly change all the paragraphs of one (unwanted) style to another (preferred) style:

  1. On the expanded Find & Replace dialog box, select Search for Styles. (If you have attributes specified, this option is labeled Including Styles.) The Search for and Replace with boxes now contain a list of styles.
  2. Select the styles you want to search for and replace.
  3. Click Find, Find All, Replace, or Replace All.


Content on this page is licensed under the Creative Common Attribution 3.0 license (CC-BY).
Personal tools