Meta Character

Metacharacters are characters that have special meaning when used in a RegExp.

\

This metacharacter indicates that the following character is not a metacharacter. It matches a literal occurrence in a test string of a character not normally interpreted literally in a regexp.

^

This matches the beginning of a string.

$

This matches the end of a string.

.

This matches any single character, including '\n'. The only character not matched (under strict POSIX) is '\0', the NUL character.

[]

Matches any single character that is included between '[' and ']'.

Certain characters need to be escaped with the '\' metacharacter: '[\\\]\-\^]' would match '\', ']', '-' or '^'.

[-]

Matches any single character whose code is included in the range. For example, '[0-9]' matches any decimal digit, while '[I-N]' matches 'I', 'J', 'K', 'L', 'M' or 'N'. Adjacent occurrences of '-' expressions match any of the ranges denoted...'[A-HO-Z]' would match any capital letter except 'I', 'J', 'K', 'L', 'M' or 'N'.

[::]

This notation is used to denote POSIX-defined "character classes."

[:alnum:] matches any alphanumeric character.

[:alpha:] ... alphabetic

[:blank:] ... blank space and tab

[:cntrl:] ... control

[:digit:] ... decimal digit

[:graph:] ... characters that are both printable and visible

[:lower:] ... lower case alpha

[:print:] ... printable (not control)

[:punct:] ... punctuation (printable, non-alphanumeric, non-whitespace)

[:space:] ... whitespace

[:upper:] ... upper case alpha

[:xdigit:] ... hex digit

[..]

"Collating symbols" are included between '[.' and '.]'. .ch. matches the collating element ch, while [ch] matches either of the letters c or h.

[==]

This is the "equivalence class" syntax. [e] would match any character considered equivalent to e, such as an e with a diacritical mark.

[^]

The caret must follow the left bracket immediately. The bracketed regexp matches any character that the regexp would have matched were the caret not present.

This is a logical "or" operator. It has the lowest precedence of any regexp operator.

()

Parentheses are used as grouping symbols to override operator precedence, as in many other syntaxes.

*

Postfix operator that matches 0 or more occurrences of the operand.

+

Postfix operator that matches 1 or more occurrences of the operand.

?

Postfix operator that matches the operand or the null string.

{,}

Hosted by www.Geocities.ws

1