Skip to content

Instantly share code, notes, and snippets.

@superbarne
Created June 9, 2013 13:44
Show Gist options
  • Save superbarne/5743599 to your computer and use it in GitHub Desktop.
Save superbarne/5743599 to your computer and use it in GitHub Desktop.
parse tags for a module system
var str = '[youtube="UKnkc-4ZzEU"]';
var ptags = [
{
name:'youtube',
search: /\[youtube\="?(.*?)"?\]/g,
replace:'<iframe width="560" height="315" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>'
}
]
for (i in ptags) {
str = str.replace(ptags[i].search, ptags[i].replace);
}
console.log(str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment