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.
$
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With