Using an example I've found here, I am trying to remove occurrences of text that are surrounded by these [
]
square brackets.
I have many occurrences of [sample-text]
in my html and want to remove the whole thing, including the brackets.
I've tried this but it doesn't work -- nothing is being replaced:
var replaced = $("body").html().replace(/^\[.*\]$/g,'');
$("body").html(replaced);
I am trying to match the start using [
and the end with ]
and remove the inner content but I am getting nowhere.