Skip to content

Instantly share code, notes, and snippets.

@icetee
Created November 18, 2020 14:20
Show Gist options
  • Save icetee/65a1c699c8eb4583598f01cb4f38de15 to your computer and use it in GitHub Desktop.
Save icetee/65a1c699c8eb4583598f01cb4f38de15 to your computer and use it in GitHub Desktop.
var shortcode = '[hello name="world"]';
var attributes = {};
shortcode.match(/[\w-]+=".+?"/g).forEach(function(attribute) {
attribute = attribute.match(/([\w-]+)="(.+?)"/);
attributes[attribute[1]] = attribute[2];
});
console.log(attributes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment