Metacharacters

General information about metacharacters.

Any single character (letter, digit, or symbol) in a regular expression is matched to itself, literally; unless it is a metacharacter. A metacharacter is one or more characters that have a unique meaning and are not used literally in the regular expression match.

For example, the circumflex character (^) is a metacharacter that means "search at the beginning".

If you want to find the character, rather than the metacharacter pattern, put a backslash (\) before it.

For example, to find the circumflex as a text character, the regular expression must be: \^

Reg. Exp.

Description

Example

\

Find the next character as a character; do not use its metacharacter pattern.

\. finds a period (.) in the text

. finds the first character (any character)

^

Find at the beginning of a string

^1 finds "1. Click Save." but not: "in the 210th line"

.

Find any character (except newline).

Finds a, A, 1, <, ., =, and so on; whatever the first character is.

()

Find a pattern group.

(word) finds "In this word"

^(Word) finds "Words in this line"

[]

Find a pattern range.

[a-z] finds letters, but not numbers

*

Find the previous pattern zero or more times.

.* finds all characters <(.*)> finds all HTML tags

+

Finds the previous pattern one or more times.

(<.l>)+ finds <UL><OL>

?

Finds the previous pattern zero or one time.

(<.l>)? finds <UL>

(?i)

Find the next characters with a case-insensitive search.

(?i)word finds word and Word