Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression match starting at the end of a Sublime Text "view"

I concocted the following regular expression, that is supposed to give me all text in the view that comes before the second to last }:

region = currentView.find("(?<=\\})[^\\}]+\\}[^\\}]*$", 0)

Sublime Text does not seem to think that $ means "end of whatever is in the view." To be honest, I don't quite understand what Sublime Text thinks it means.

My regular expression seems to work, as shown here on regexr.com.

I found a workaround for my particular cirmunstance that I can live with for the moment:

regions = currentView.find_all("\}")
    if len(regions) > 1:
        # stuff I am doing with regions[-2] goes here

but I would like to know if it is possible to match against the end of the view's content.

like image 787
DudeOnRock Avatar asked Oct 21 '13 18:10

DudeOnRock


1 Answers

$ at the end of a regex can mean either the end of line or the end of the input, depending on the engine and modifier flags that are passed in. A quick look at Sublime's doc show that it supports the \z boundary, which unequivocally means "the end of the input buffer". So try replacing your final $ with \z, to see if that helps.

like image 117
jwatkins Avatar answered Nov 14 '22 21:11

jwatkins