Lista wyrażeń regularnych

Wyrażenie

Znaczenie i użycie

Dowolny znak

Podany znak, chyba że jest to metaznak wyrażenia regularnego. Lista metaznaków znajduje się w tej tabeli.

.

Dowolny pojedynczy znak z wyjątkiem końca wiersza lub końca akapitu. Na przykład wyszukiwane hasło „b.s” pasuje zarówno do „bus”, jak i „bas”.

^

Początek akapitu lub komórki. Obiekty specjalne, takie jak puste pola lub ramki zakotwiczone w znakach, na początku akapitu są ignorowane. Przykład: „^Piotr” pasuje do słowa „Piotr” tylko wtedy, gdy jest to pierwsze słowo akapitu.

$

Koniec akapitu lub komórki. Obiekty specjalne, takie jak puste pola lub ramki zakotwiczone w znakach na końcu akapitu, są ignorowane. Przykład: „Piotr$” pasuje tylko wtedy, gdy słowo „Piotr” jest ostatnim słowem akapitu, należy pamiętać, że słowa „Piotr” nie może poprzedzać kropka.

$ sam zgodny jest z końcem akapitu. W ten sposób możesz wyszukać i zastąpić podział akapitu.

*

Zero lub więcej terminu wyrażenia regularnego bezpośrednio go poprzedzającego. Na przykład „Ab*c” pasuje do „Ac”, „Abc”, „Abbc”, „Abbbc” itd.

+

Co najmniej jeden termin wyrażenia regularnego bezpośrednio go poprzedzający. Na przykład „AX.+4” spowoduje znalezienie „AXx4”, ale nie „AX4”.

Zawsze dopasowywany jest najdłuższy możliwy ciąg pasujący do tego wyrażenia regularnego w akapicie. Jeśli akapit zawiera ciąg „AX 4 AX4”, cały fragment jest wyróżniony.

?

Zero lub jeden z terminów wyrażenia regularnego bezpośrednio go poprzedzający. Na przykład „Teksty?” pasuje do „Tekst” i „Teksty”, a „x(ab|c)?y” powoduje znalezienie „xy”, „xaby” lub „xcy”.

\

Następujący po nim znak specjalny jest interpretowany jako zwykły znak, a nie jako metaznak wyrażenia regularnego (z wyjątkiem kombinacji „\n”, „\t”, „\b”, „\>” i „\<”) . Na przykład „drzewo\”. dopasowuje „drzewo”, a nie „drzewu” lub „drzewa”.

\n

Po wprowadzeniu w polu tekstowym Znajdź znajduje koniec wiersza, który został wstawiony za pomocą kombinacji klawiszy Shift+Enter w programie Writer lub Ctrl+Enter kombinację klawiszy w komórce Calc.

When entered in the Replace text box in Writer, inserts a paragraph break that can be inserted with the Enter or Return key. Has no special meaning in Calc, and is treated literally there.

Aby zmienić podział wiersza na podział akapitu w programie Writer, wpisz \n w obu polach Znajdź i Zamień, a następnie przeprowadź wyszukiwanie i zamianę.

\t

Znak tabulacji. Można również użyć w polu Zamień.

\b

Granica słowa. Na przykład „\bwaga” pasuje do „wagant” i „waga”, ale nie do „równowaga”, podczas gdy „waga\b” pasuje do „równowaga” i „waga”, ale nie do „wagant”.

Zauważ, że ten formularz zastępuje przestarzałe (chociaż nadal działające) formularze „\>” (dopasowuje koniec słowa) i „\<” (dopasowuje początek słowa).

^$

Znajduje pusty akapit.

^.

Znajduje pierwszy znak akapitu.

& lub $0

Dodaje ciąg znaleziony przez kryteria wyszukiwania w polu Znajdź do terminu w polu Zamień, gdy dokonujesz zamiany.

Na przykład, jeśli wpiszesz "rama" w polu Znajdź i "&anty" w polu Zamień, słowo "rama" zostanie zastąpione słowem "antyrama".

Możesz także wpisać znak „&” w polu Zamień, aby zmodyfikować Atrybuty lub Format ciągu znalezionego według kryteriów wyszukiwania.

[...]

Dowolne pojedyncze wystąpienie dowolnego znaku znajdującego się w nawiasach. Na przykład: „[abc123]” odpowiada znakom „a”, „b”, „c”, „1”, „2” i „3”. „[a-e]” dopasowuje pojedyncze wystąpienia znaków od a do e włącznie (zakres musi być określony, zaczynając od znaku o najmniejszym numerze kodu Unicode). „[a-eh-x]” pasuje do każdego pojedynczego wystąpienia znaków z zakresu od „a” do „e” i od „h” do „x”.

[^...]

Any single occurrence of a character, including Tab, Space and Line Break characters, that is not in the list of characters specified inclusive ranges are permitted. For example "[^a-syz]" matches all characters not in the inclusive range ‘a’ through ‘s’ or the characters ‘y’ and ‘z’.

\uXXXX

\UXXXXXXXX

The character represented by the four-digit hexadecimal Unicode code (XXXX).

The character represented by the eight-digit hexadecimal Unicode code (XXXXXXXX).

For certain symbol fonts the symbol (glyph) that you see on screen may look related to a different Unicode code than what is actually used for it in the font. The Unicode codes can be viewed by choosing Insert - Special Character, or by using Unicode conversion shortcut.

|

The infix operator delimiting alternatives. Matches the term preceding the "|" or the term following the "|". For example, "this|that" matches occurrences of both "this" and "that".

{N}

The post-fix repetition operator that specifies an exact number of occurrences ("N") of the regular expression term immediately preceding it must be present for a match to occur. For example, "tre{2}" matches "tree".

{N,M}

The post-fix repetition operator that specifies a range (minimum of "N" to a maximum of "M") of occurrences of the regular expression term immediately preceding it that can be present for a match to occur. For example, "tre{1,2}" matches "tre" and "tree".

{N,}

The post-fix repetition operator that specifies a range (minimum "N" to an unspecified maximum) of occurrences of the regular expression term immediately preceding it that can be present for a match to occur. (The maximum number of occurrences is limited only by the size of the document). For example, "tre{2,}" matches "tree", "treee", and "treeeee".

(...)

The grouping construct that serves three purposes.

  1. To enclose a set of ‘|’ alternatives. For example, the regular expression "b(oo|ac)k" matches both "book" and "back".

  2. To group terms in a complex expression to be operated on by the post-fix operators: "*", "+" and "?" along with the post-fix repetition operators. For example, the regular expression "a(bc)?d" matches both "ad" and "abcd" in a search.; the regular expression "M(iss){2}ippi" matches "Mississippi".

  3. To record the matched sub string inside the parentheses as a reference for later use in the Find box using the "\n" construct or in the Replace box using the "$n" construct. The reference to the first match is represented by "\1" in the Find box and by "$1" in the Replace box. The reference to the second matched sub string by "\2" and "$2" respectively, and so on.

For example, the regular expression "(890)7\1\1" matches "8907890890".

With the regular expression "\b(fruit|truth)\b" in the Find box and the regular expression "$1ful" in the Replace box occurrences of the words "fruit" and "truth" can be replaced with the words "fruitful" and "truthful" respectively without affecting the words "fruitfully" and "truthfully"

[:alpha:]

Represents an alphabetic character. Use [:alpha:]+ to find one of them.

[:digit:]

Represents a decimal digit. Use [:digit:]+ to find one of them.

[:alnum:]

Oznacza znak alfanumeryczny ([:alpha:] i [:digit:]).

[:space:]

Przedstawia znak spacji (ale żaden inny znak specjalny).

[:print:]

Oznacza znak drukowalny.

[:cntrl:]

Oznacza znak niedrukowalny.

[:lower:]

Oznacza małą literę, o ile w sekcji Opcje zaznaczono pole wyboru Uwzględniaj wielkość liter.

[:upper:]

Represents an uppercase character if Match case is selected in Options.


For a full list of supported metacharacters and syntax, see ICU Regular Expressions documentation

Regular expression terms can be combined to form complex and sophisticated regular expressions for searches as show in the following examples.

Przykłady

Expression

Meaning

^$

An empty paragraph.

^ specifies that the match must be at the start of a paragraph,

$ specifies that a paragraph mark or the end of a cell must follow the matched string.

^.

The first character of a paragraph.

^ specifies that the match must be at the start of a paragraph,

. specifies any single character.

e([:digit:])?

Matches "e" by itself or an "e" followed by one digit.

e specifies the character "e",

[:digit:] specifies any decimal digit,

? specifies zero or one occurrences of [:digit:].

^([:digit:])$

Matches a paragraph or cells containing exactly one digit.

^ specifies that the match must be at the start of a paragraph,

[:digit:] specifies any decimal digit,

$ specifies that a paragraph mark or the end of a cell must follow the matched string.

^[:digit:]{3}$

Matches a paragraph or cell containing only three digit numbers

^ specifies that the match must be at the start of a paragraph,

[:digit:] specifies any decimal digit,

{3} specifies that [:digit:] must occur three times,

$ specifies that a paragraph mark or the end of a cell must follow the matched string.

\bconst(itu|ruc)tion\b

Matches the words "constitution" and "construction" but not the word "constitutional."

\b specifies that the match must begin at a word boundary,

const specifies the characters "const",

( starts the group,

itu specifies the characters "itu",

| specifies the alternative,

ruc specifies the characters "ruc",

) ends the group,

tion specifies the characters "tion",

\b specifies that the match must end at a word boundary.