Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between ^ and \A , $ and \Z in regex?

Tags:

In regular expressions:

  • What is the difference between ^ and \A?
  • What is the difference between $ and \Z?
like image 746
Rohit Chauhan Avatar asked Nov 22 '10 20:11

Rohit Chauhan


1 Answers

In single-line mode, $ matches either the end of the string, or just before the newline at the end of the string. In multiline mode $ matches before each newline in the string. \Z always matches only the end of the string regardless of the line mode. Same with ^ versus \A.

like image 177
Ignacio Vazquez-Abrams Avatar answered Oct 20 '22 20:10

Ignacio Vazquez-Abrams