PHP Terms Regular Expressions POSIX Brackets

 

- Info:

- Square brackets [] are used to represent a set or range of characters like: [abcA-Z09]

Range is defined by using '-' between characters represeting start and end of range.

Set is defined by simply entering characters or ranges.

Single brackets can contain multiple sets and ranges.

- Curly brackets () are used to defined exact sequence of characters like: (abc).

 

    

EXAMPLE

DESCRIPTION

 

 

[0-9]

Represents any digit.

(Range of digits between 0 and 9)

 

[a-z]

Represents any lowercase letter.

(Range of letters between a and z)

 

[A-Z]

Represents any uppercase letter.

(Range of letters between A and Z)

 

[A-Za-z]

Represents any letter.

(Ranges of letters between A-Z and a-z)

 

[A-Za-z0-9]

Represents any digit or letter.

(Ranges of letters and digits)

 

[aDf]

Represents A, D or f letter.

(Set of characters)

 

[45d-tDgh]

Represents characters 4, 5, D, g, h and any character in the range d-t.

 

(bc)

Represents exact sequence of charcters bc.

 

[(bc)a-z(09)]

Represents exact sequence bc or 09 or any charactes from a-z.

 

[^A-Za-z]

Matches any string NOT containing any of the characters from a-z and A-Z.

 

[^aDf]

Matches any string NOT containing any of the A, D or f letters.