The following characters have special meaning in search patterns:
Many utilities support POSIX character lists, which are useful for matching non-ASCII characters in languages other than English. These lists are recognized only within [] ranges. A typical use would be [[:lower:]], which in English is the same as [a-z].
The following table lists POSIX character lists:
Notation | Action |
---|---|
[:alnum:] | Alphanumeric characters |
[:alpha:] | Alphabetic characters, uppercase and lowercase |
[:blank:] | Printable whitespace: spaces and tabs but not control characters |
[:cntrl:] | Control characters, such as ^A through ^Z |
[:digit:] | Decimal digits |
[:graph:] | Printable characters, excluding whitespace |
[:lower:] | Lowercase alphabetic characters |
[:print:] | Printable characters, including whitespace but not control characters |
[:punct:] | Punctuation, a subclass of printable characters |
[:space:] | Whitespace, including spaces, tabs, and some control characters |
[:upper:] | Uppercase alphabetic characters |
[:xdigit:] | Hexadecimal digits |
The following characters have special meaning in replacement patterns:
Character | Meaning |
---|---|
\ | Turn off the special meaning of the character that follows. |
\n | Restore the nth pattern previously saved by \( and \). n is a number from 1 to 9, matching the patterns searched sequentially from left to right. |
& | Reuse the search pattern as part of the replacement pattern. |
~ | Reuse the previous replacement pattern in the current replacement pattern. |
\e | End replacement pattern started by \L or \U. |
\E | End replacement pattern started by \L or \U. |
\l | Convert first character of replacement pattern to lowercase. |
\L | Convert replacement pattern to lowercase. |
\u | Convert first character of replacement pattern to uppercase. |
\U | Convert replacement pattern to uppercase. |
Copyright © 2001 O'Reilly & Associates. All rights reserved.