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
Post a Comment