Some regular expression metacharacters
are valid for one program but not for another. Those that are
available to a particular Unix program are marked by a check
() in Table 32-5. Quick reference
descriptions of each of the characters can be found in Section 32.21.
[Unfortunately, even this table doesn't give the whole story. For example, Sun has taken some of the extensions originally developed for ed, ex, and vi (such as the \< \> and \{min, max\} modifiers) and added them to other programs that use regular expressions. So don't be bashful -- try things out, but don't be surprised if every possible regular expression feature isn't supported by every program. In addition, there are many programs that recognize regular expressions, such as perl, emacs, more, dbx, expr, lex, pg, and less, that aren't covered in Daniel's table. -- TOR]
In ed , ex, and sed, note that you specify both a search pattern (on the left) and a replacement pattern (on the right). The metacharacters in Table 32-5 are meaningful only in a search pattern. ed, ex, and sed support the additional metacharacters in Table 32-6 that are valid only in a replacement pattern.
Symbol |
ex |
sed |
ed |
Action |
---|---|---|---|---|
\ |
|
|
|
Escape character following. |
\n |
|
|
|
Reuse pattern stored by \( \) pair number \n. |
& |
|
|
Reuse previous search pattern. |
|
~ |
|
Reuse previous replacement pattern. |
||
\u \U |
|
Change character(s) to uppercase. |
||
\l \L |
|
Change character(s) to lowercase. |
||
\E |
|
Turn off previous \U or \L. |
||
\e |
|
Turn off previous \u or \l. |
-- DG
Copyright © 2003 O'Reilly & Associates. All rights reserved.