Cloud

POSIX Regular Expressions

POSIX (Portable Operating System Interface) defines a set of standard operating system interfaces based on the UNIX OS. In POSIX Basic Regex Expression (BRE) syntax, most characters are treated as literals (for example, they match only themselves). However, some characters called metacharacters have special meaning.

This table describes common POSIX BRE metacharacters:

Metacharacter Description

.

Matches any single character. For example, a.c matches “abc”, but [a.c] matches only “a”, “.”, or “c

-

Used to define a range. For example, [a-c] will match characters a to c (both inclusive)

[]

Matches a literal character

^

Matches the beginning of a line

$

Matches the end of a line

*

Matches zero or more occurrences of the preceding element

{n}

Matches exactly n occurrences of the preceding element

\{n,m}

Matches between n and m occurrences of the preceding element