Anchor Characters: Caret (^)

Download regex eBook

Remarks

Terminology

The Caret (^) character is also referred to by the following terms:

  • hat
  • control
  • uparrow
  • chevron
  • circumflex accent

Usage

It has two uses in regular expressions:

  • To denote the start of the line
  • If used immediately after a square bracket ([^) it acts to negate the set of allowed characters (i.e. [123] means the character 1, 2, or 3 is allowed, whilst the statement [^123] means any character other than 1, 2, or 3 is allowed.

Character Escaping

To express a caret without special meaning, it should be escaped by preceding it with a backslash; i.e. \^.

Related Examples

Stats

550 Contributors: 14
Sunday, April 30, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook