so you don't know what comes before, you don't know what the word-to-replace will be and you don't know what comes after? i think you'll have to know something about what you're dealing with.
OK, so do you mean a function like...
var pattern = new RegExp(search,"g");
var search = 'me';
var replace = 'you';
var string = 'help me to help you';
Obviously the variables can be set from anything you want