I felt the need for double-curly-bracket-enclosed-placeholders for translation purposes. I didn't want to use single-brackets. (Used to Angular, sorry. ;))
It's actually quite simple what it does: Check for double curly-brackets, and make sure that after it, there's no curly bracket.
\{\{(?!{)(.*?)\}\}
Credits for the single-bracket method, on which this was enhanced: Paul Dixon
I'm not really sure, but depending on the "executing language" you could remove the backslahes ("\") before the curely-brackets.
\{
matches the character{
literally\{
matches the character{
literally(?!{)
Negative Lookahead - Assert that it is impossible to match the regex below{
matches the character{
literally
- 1st Capturing group
(.*?)
.*?
matches any character (except newline)- Quantifier:
*?
Betweenzero
andunlimited
times, as few times as possible, expanding as needed[lazy]
- Quantifier:
\}
matches the character}
literally\}
matches the character}
literally
Explaination format by: Regex101
This is a {{arg1}}. It has been created by: {{name}} on {{date}}. Note: {{{note}}}
This will create four groups:
{{arg1}}
{{name}}
{{date}}
{{note}}
These can now be replaced using your favourite language. The result will be something like this:
This is a test. It has been created by: Eddie on 2016-07-29. Note: {Yes, even this works!}