Contents

  Icon

Anchoring expressions

Anchors

Basic metacharacters

Character classes

Comments

Control and code

Grouping

Look around

Mode modifiers

Quantifiers

Specific characters

Anchors are used to tie (part of) an expression to a certain position.


 

Item

 

Matches at:

 
 

^

 

Start of a string.
If used in multiline mode also matches beginning of each line, (i.e. after a newline).

 
 

$

 

End of a string.
If used in multiline mode also matches end of each line, (i.e. before a newline).

 
 

\A

 

Start of a string.

 
 

\b

 

Word boundary.
This is the position between an \W and \w or between \w and \W. (In a character class \b represents a backspace.)

 
 

\B

 

Any position that is not a word boundary.

 
 

\z

 

End of string.

 

\Z

End of string if the string does not end with a newline. If it ends with a newline \Z matches just before that.