Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
for(i = 0; i < parent_names.length; i++) {
if(parent_ids[i]) {
/*
content = content.replace(
new RegExp('(\[' + parent_names[i] + '\])\[.+?\]', 'g'),
'$1[' + parent_ids[i] + ']'
)
*/
var regexp_string = '\\[' + parent_names[i] + '\\]\\[.+?\\]';
var regexp = new RegExp(regexp_string, 'g');
var replacement = '[' + parent_names[i] + '][' + parent_ids[i] + ']';
content = content.replace(regexp,replacement);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment