Skip to content

Instantly share code, notes, and snippets.

@netProphET
Created September 15, 2010 15:30
Show Gist options
  • Save netProphET/580902 to your computer and use it in GitHub Desktop.
Save netProphET/580902 to your computer and use it in GitHub Desktop.
regexp = /(\[\[[^\]]*)&([^\[]*\]\])/g;
tests = [
"",
"no modx tags",
"[[something?&foo=`bar`]]",
"[[something? &foo=`[[$bar &baz=`fuz`]]`]]",
"[[something? &replace=`yes`]] & don't replace",
"[[something? &replace=`yes`]] & don't replace [[something? &replace=`yes`]]",
"[[line1? &foo=`bar`]] & don't replace\n[[line2? &bar=`baz`]]"
];
for(i in tests) {
console.log(tests[i].replace(regexp, '$1&$2'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment