Your regex
{{[^}}]*}}
Does not work (try it), because the [^}}]
will not allow it to go past the first* close curly. If you want to capture "all close curlys except the last two", then you need
\{\{.*\}\}[ ]+
Try it
I'm escaping the curlies to be safe. Although it works without them in regexstorm, they're special characters, and they should be escaped. I've also added the trailing space, to only capture the post-text, as you wish.
Note that this regex does not check that the curlies are balanced--it just blindly matches from the first two open curlies, to the last two. Regex is not suited to determining "balanced-ness".
(*The first, because the [^}}]
is incorrect. The [^...]
is a negative character class--it matches any one character that is not in the class (between the square brackets). So [^}}]
is equivalent to [^}}}}}}}}}}}}}}}]
is equivalent to [^}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}]
.)
Please consider bookmarking the Stack Overflow Regular Expressions FAQ for future reference.