@@ -388,10 +388,17 @@ class RegExp extends AST::RegExpLiteral {
388388
389389 predicate specialCharacter ( int start , int end , string char ) {
390390 this .character ( start , end ) and
391- end = start + 1 and
392- char = this .getChar ( start ) and
393- ( char = "$" or char = "^" or char = "." ) and
394- not this .inCharSet ( start )
391+ not this .inCharSet ( start ) and
392+ (
393+ end = start + 1 and
394+ char = this .getChar ( start ) and
395+ ( char = "$" or char = "^" or char = "." )
396+ or
397+ end = start + 2 and
398+ this .escapingChar ( start ) and
399+ char = this .getText ( ) .substring ( start , end ) and
400+ char = [ "\\A" , "\\Z" , "\\z" ]
401+ )
395402 }
396403
397404 /** Whether the text in the range `start,end` is a group */
@@ -808,10 +815,8 @@ class RegExp extends AST::RegExpLiteral {
808815 or
809816 this .qualifiedItem ( x , start , true , _)
810817 or
811- this .specialCharacter ( x , start , "^" )
812- or
813- // \A matches the start of the string
814- x = start - 2 and this .escapingChar ( x ) and this .getChar ( x + 1 ) = "A"
818+ // ^ and \A match the start of the string
819+ this .specialCharacter ( x , start , [ "^" , "\\A" ] )
815820 )
816821 or
817822 exists ( int y | this .firstPart ( start , y ) |
@@ -836,9 +841,8 @@ class RegExp extends AST::RegExpLiteral {
836841 or
837842 this .qualifiedItem ( end , y , true , _)
838843 or
839- this .specialCharacter ( end , y , "$" )
840- or
841- y = end + 2 and this .escapingChar ( end ) and this .getChar ( end + 1 ) = "Z"
844+ // $, \Z, and \z match the end of the string.
845+ this .specialCharacter ( end , y , [ "$" , "\\Z" , "\\z" ] )
842846 )
843847 or
844848 exists ( int x |
0 commit comments