Reputation: 687
In sublime text 3, why does this match 3 entries
\$http\.post\('\/((?!view|list).)[^\']*'
but this matches nothing
\$http\.post\('\/((?!view|list).)[^\']*\'
on the following dataset.
$http.post('/listSets' ,$scope.updateAccessKey({type: 2}), {
$http.post('/viewedMessage' , viewedMessagePayload, {
$http.post('/listRelatedContent' ,
$http.post('/viewedSet' , payLoad , {
$http.post('/viewDiscussion' , payLoad , {
$http.post('/editMessage' , $scope.updateAccessKey(payLoad), {
$http.post('/addComment' , $scope.updateAccessKey(payLoad), {
$http.post('/createStudySet' , createSetP
I know that escaping the apostrophe is optional but why does it break Sublime Text regex search?
Upvotes: 1
Views: 678
Reputation: 22821
Per the documentation on Search and Replace, internally Sublime uses the Boost PCRE engine to power regular expressions in search panels, and according to the Boost Regex documentation, the construct \'
is synonymous with \z
and matches only at the end of a buffer.
So the version of your regex that ends in \'
doesn't match anything because by definition it only matches something that looks like a $http.post
line which appears in the last line of the file and which ends the file with the URL string still unterminated.
Due to the *
prior to \'
in the regex, it will match any amount of text that follows such a line, so long as it doesn't contain a single quote (due to the exclusion in the character class).
For example, given the following input, your regex will match the last $http.post
, including everything following it right up to the end of the buffer.
$http.post('/listSets' ,$scope.updateAccessKey({type: 2}), {
$http.post('/viewedMessage' , viewedMessagePayload, {
$http.post('/listRelatedContent' ,
$http.post('/viewedSet' , payLoad , {
$http.post('/viewDiscussion' , payLoad , {
$http.post('/editMessage' , $scope.updateAccessKey(payLoad), {
$http.post('/addComment' , $scope.updateAccessKey(payLoad), {
$http.post('/createStudySet , $scope.updateAccessKey(payLoad), {
And then some other non code stuff here.
Basically anything but a single quote.
Upvotes: 4