正規表現のリスト
記号 |
作用と用途 |
すべての文字 |
指定しない場合、所定の文字列を表します。 |
. |
行ブレークと段落ブレーク以外のすべての単一文字を表します。たとえば、検索語として「sh.rt」を指定すると、「shirt」と「short」の両方が戻されます。 |
^ |
検索語句が段落の先頭にある場合にのみ検索されます。段落の先頭にある特殊オブジェクト (空のフィードや文字にアンカーされた枠) は無視されます。たとえば、「^Peter」です。 |
$ |
検索語句が段落の末尾にある場合にのみ検索されます。段落の末尾にある特殊なオブジェクト (空のフィールドや文字にアンカーされた枠) は無視されます。たとえば、「Peter$」などです。 $ on its own matches the end of a paragraph. This way it is possible to search and replace paragraph breaks. |
* |
「*」の前の文字が 0 個以上の語句が検索されます。例えば「Ab*c」では、「Ac」、「Abc」、「Abbc」、「Abbbc」などが検索されます。 |
+ |
「+」記号の前の文字が 1 個以上の語句が検索されます。たとえば、「AX.+4」とすると「AX 4」は検索されますが「AX4」は検索されません。 段落内で可能な限り長いテキストが常に検索されます。段落にテキスト「AX 4 AX4」が含まれている場合、先頭の A から末尾の 4 までが検索されます。 |
? |
「?」 の直前にある文字が0回または1回出現することを示します。たとえば 「テキ?ト」 と指定すると 「テスト」 と 「テキスト」 が検索されます。「x(ab|c)?y」 と指定すると 「xaby」 や 「xcy」 が検索されます。 |
\ |
正規表現ではなく、通常の文字として「\」の後ろに続く特殊文字を検索します (\n、 \t、 \>、 \< の組み合わせは除きます)。たとえば「tree\.」は、「tree.」を検索します。「treed」あるいは「trees」などは検索できません。 |
\n |
Represents a line break that was inserted with the Shift+Enter key combination. To change a line break into a paragraph break, enter \n in the Find and Replace boxes, and then perform a search and replace. \n in the Find text box stands for a line break that was inserted with the Shift+Enter key combination. \n in the Replace text box stands for a paragraph break that can be entered with the Enter or Return key. |
\t |
Represents a tab. You can also use this expression in the Replace box. |
\b |
Match a word boundary. For example, "\bbook" finds "bookmark" but not "checkbook" whereas "book\b" finds "checkbook" but not "bookmark". The discrete word "book" is found by both search terms. |
^$ |
空の段落が検索されます。 |
^. |
段落の最初の文字が検索されます。 |
& または $0 |
Adds the string that was found by the search criteria in the Find box to the term in the Replace box when you make a replacement. For example, if you enter "window" in the Find box and "&frame" in the Replace box, the word "window" is replaced with "windowframe". You can also enter an "&" in the Replace box to modify the Attributes or the Format of the string found by the search criteria. |
[abc123] |
かっこで囲まれた文字の 1 つを表します。 |
[a-e] |
a と e の間の文字を表します。両端の文字、この例では a と e を含みます。 文字の順序は文字コードの番号順です。 |
[a-eh-x] |
a ~ e と h ~ x 間の文字を表します。 |
[^a-s] |
a から s までに含まれないすべての文字を表します。 |
\uXXXX \UXXXXXXXX |
Represents a character based on its four-digit hexadecimal Unicode code (XXXX). For obscure characters there is a separate variant with capital U and eight hexadecimal digits (XXXXXXXX). For certain symbol fonts the code for special characters may depend on the used font. You can view the codes by choosing Insert - Special Character. |
| |
「|」より前の条件で検索して、その後に「|」より後の条件で検索します。例えば、「これ | それ」は「これ」と「それ」を検索します。 |
{2} |
開きかっこの左側にある文字の発生回数を指定します。例えば「tre{2}」を指定すると、「tree」が検索されます。 |
{1,2} |
開きかっこの前にある文字の繰りかえしの最小回数と最大回数を指定します。たとえば、「tre{1,2}」と指定すると、「tre」、および「tree」が検索されます。 |
{1,} |
左角括弧の前にある文字の繰りかえしの最小回数を指定します。たとえば、「tre{2,}」と指定すると、「tree」、「treee」、および「treeeee」が検索されます。 |
( ) |
In the Find box: かっこ内の文字を参照対象として定義します。すると、現在の式で最初の参照対象を「\1」、第 2 の参照対象を「\2」、以降同様にして参照することができます。 たとえば、テキストに 13487889 という数字が含まれている場合に、「(8)7\1\1」という正規表現で検索すると、「8788」が検索されます。 () で囲んで語句をグループ化できます。たとえば、「a(bc)?d」では「ad」または「abcd」が検索されます。 In the Replace box: 参照を置き換えるには、\ (バックスラッシュ) ではなく $ (ドル記号) を使用します。 見つかった文字列全体を置き換えるには $0 を使用します。 |
[:alpha:] |
Represents an alphabetic character. Use [:alpha:]+ to find one or more of them. |
[:digit:] |
Represents a decimal digit. Use [:digit:]+ to find one or more of them. |
[:alnum:] |
英数文字 ([:alpha:] と [:digit:]) を表します。 |
[:space:] |
空白文字です (その他の空白類文字ではありません)。 |
[:print:] |
プリント可能文字を表します。 |
[:cntrl:] |
編集記号を表します。 |
[:lower:] |
オプション の 大文字と小文字を区別する がオンにされていると、小文字を検索します。 |
[:upper:] |
オプション で 大小文字を区別する がオンにされている場合には、大文字を表します。 |
例
e([:digit:])? -- finds 'e' followed by zero or one digit. Note that currently all named character classes like [:digit:] must be enclosed in parentheses.
^([:digit:])$ -- finds lines or cells with exactly one digit.
検索語を組み合わせて、複雑な検索を作成できます。
段落内の 3 桁の数字だけを検索する
^[:digit:]{3}$
「^」は、段落の先頭で一致しなければならないことを意味しています。
[:digit:]10 進数の数字と一致します。
{3} は、正確に 3 コピーの「桁」でなければならないことを意味しています。
「$」は段落の最後で一致しなければならないことを意味します。