javascript - do the opposite of a regex split -


i have string so:

var string = "{{ \"foo {0}\" | i18n:[\"bar\"] }}"; 

what want values in quotes, can achieve regex /".*?"/.

but when sprint, doesn't return what's in quotes, outside of them.

string.split(/".*?"/); 

returns

[ '{{ ', ' | i18n }}' ] 

you'll need use .match

you want capture things inside quotes, you'll add capturing expression.

var exp = /"(.*?)"/; string.match(exp); 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -