Použití regulárních výrazů při vyhledávání textu

Regular expressions are special patterns used to find and manipulate text, helping you locate specific information within texts.

note

Vyhledávání pomocí regulárních výrazů se liší od vyhledávání se zástupnými znaky. LibreOffice Writer umožňuje pouze vyhledávání s regulárními výrazy.


Při hledání a nahrazování textu je možné použít regulární výrazy. Například při zadání „m.j“ budou nalezena slova „můj“ i „máj“.

  1. Vyberte Úpravy - Najít a nahradit.

  2. Dialogové okno rozšíříte klepnutím na tlačítko Ostatní možnosti.

  3. Zaškrtněte pole Regulární výrazy.

  4. V poli Hledat zadejte hledaný výraz včetně požadovaných regulárních výrazů.

  5. Klepněte na Najít další nebo Najít vše.

Příklady regulárních výrazů

  1. Regulární výraz pro jediný znak je tečka (.).

  2. The regular expression for a word character \w, and \d for a decimal digit.

  3. Regulární výraz pro žádný nebo více výskytů předchozího znaku je hvězdička. Příklad: „123*“ najde „12“, „123“ i „1233“.

  4. The regular expression to search for zero or more occurrences of any character is a period and asterisk (.*).

  5. The regular expression for one or more occurrences of the previous character is a plus sign (+). For example: "\w+" finds any word, "\d+" any number.

  6. The regular expression for a tab character is \t. More generally, \s stands for all kinds of "spaces", like non-breaking space, carriage return ...

  7. The regular expression for the end of a paragraph is a dollar sign ($). The regular expression for the start of a paragraph is a caret and a period (^.). The regular expression for an empty paragraph is ^$.

Ikona poznámky

A search using a regular expression will work only within one paragraph. That is, a \n will match a line break within a paragraph.