I'm currently working on a set of components (http://github.com/bredele) that you can assemble to get the same kind of features that you have in some JavaScript framework such as Olives.js, Canjs or Angular.
One of the component allows you to bind live dom to an object with handlebars.I use the regex (/{([^}]+)}/g) to match only simple handlebars. I would like to match double handlebars as following:
before:
{label} //return 'label'
after:
{label} //return 'label'
{{label}} //return '{label}'
The regex should allow the two use cases. Any idea?
Thanls
/{([^{}]+)}/g
should have the behavior you describe:
"cat dog".replace(/{([^{}]+)}/g, "$1") => "cat dog"
"{cat} {dog}".replace(/{([^{}]+)}/g, "$1") => "cat dog"
"{{cat}} {{dog}}".replace(/{([^{}]+)}/g, "$1") => "{cat} {dog}"
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