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.
$
in regex means "end of string". So is your end of view the end of the string ?\\}
? Isn't\}
enough if you want to match a literal}
?/
symbol to be escaped.