Regular and manual control

I am currently working on a set of components ( http://github.com/bredele ) that you can build to get the same functions as you do in some JavaScript structures such as Olives.js, Canjs or Angular.

One of the components allows you to associate a live dom with an object with handlebars. I use regex (/ {([^}] +)} / g) to fit only simple rudders. I would like to combine dual rudders as follows:

before:

{label} // return 'label'

after

{label} // return 'label'

{{label}} // return '{label}'

A regular expression must allow two uses. Any idea?

Thanls

+4
1

/{([^{}]+)}/g :

"cat dog".replace(/{([^{}]+)}/g, "$1") => "cat dog"
"{cat} {dog}".replace(/{([^{}]+)}/g, "$1") => "cat dog"
"{{cat}} {{dog}}".replace(/{([^{}]+)}/g, "$1") => "{cat} {dog}"
+7

All Articles