Consider the following very simplified example:
var some_module = {
    func_a: function() {
        return 'a';
    },
    func_b: function(character) {
        if (character == 'b') {
            console.log(this); //refers to window
            return this.func_a;
        } else {
            return 'X';
        }
    },
    func_c: function() {
        console.log(this); //refers to some_module
        return "abcdefgh".replace(/[abc]/g, this.func_b);
    }
};
some_module.func_c();
This fails because in func_b, "this" refers to window because of the call context (as far as i know). I am aware of workarounds, that usually work when nesting functions, however how can I get it to work in this case where the function is used as a callback in .replace()?
 
     
    