+ 3

Are /A and /Z the same as ^ and $?

24th Feb 2016, 4:26 AM
Junjie
Junjie - avatar
2 Antworten
+ 9
^ Matches the beginning of a line. $ Matches the end of a line. \A Matches the beginning of the string. \z Matches the end of the string. \Z Matches the end of the string unless the string ends with a "\n", in which case it matches just before the "\n". /^foo$/ matches any of the following, /\Afoo\z/ does not: whatever1 foo whatever --- foo whatever2 --- whatever1 foo /^foo$/ and /\Afoo\z/ all match the following: foo
23rd May 2016, 4:39 PM
James Flanders
+ 1
Strictly...no...because line/string are different concepts and also syntax: although we know what you mean the parser will not: / is not \. (Sure it's a rigid answer, but you're contrasting strings with metacharacters and regex cares)
30th Sep 2016, 6:10 AM
Kirk Schafer
Kirk Schafer - avatar