dist/utilify.esm.js
function strReplace(search, replace, subject) {
        var regex = void 0;

        if (validateHelpers.isArray(search)) {
            for (var i = 0; i < search.length; i++) {
                search[i] = search[i].replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
                regex = new RegExp(search[i], 'g');
                subject = subject.replace(regex, validateHelpers.isArray(replace) ? replace[i] : replace);
            }
        } else {
            search = search.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
            regex = new RegExp(search, 'g');
            subject = subject.replace(regex, validateHelpers.isArray(replace) ? replace[0] : replace);
        }

        return subject;
    }
function strReplace(search, replace, subject) {
        var regex = void 0;

        if (validateHelpers.isArray(search)) {
            for (var i = 0; i < search.length; i++) {
                search[i] = search[i].replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
                regex = new RegExp(search[i], 'g');
                subject = subject.replace(regex, validateHelpers.isArray(replace) ? replace[i] : replace);
            }
        } else {
            search = search.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
            regex = new RegExp(search, 'g');
            subject = subject.replace(regex, validateHelpers.isArray(replace) ? replace[0] : replace);
        }

        return subject;
    }
function strReplace ( search , replace , subject ) { var regex = void 0 ; if ( validateHelpers . isArray ( search ) ) { for ( var i = 0 ; i < search . length ; i ++ ) { search [ i ] = search [ i ] . replace ( / [\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|] / g , '\\$&' ) ; regex = new RegExp ( search [ i ] , 'g' ) ; subject = subject . replace ( regex , validateHelpers . isArray ( replace ) ? replace [ i ] : replace ) ; } } else { search = search . replace ( / [\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|] / g , '\\$&' ) ; regex = new RegExp ( search , 'g' ) ; subject = subject . replace ( regex , validateHelpers . isArray ( replace ) ? replace [ 0 ] : replace ) ; } return subject ; }
Multiple string replace, PHP str_replace clone
@param {string|Array} search - The value being searched for, otherwise known as the needle.
An array may be used to designate multiple needles.
@param {string|Array} replace - The replacement value that replaces found search values.
An array may be used to designate multiple replacements.
@param {string} subject - The subject of the replacement
@return {string} The modified string
@example
strReplace(['olá', 'mundo'], ['hello', 'world'], 'olá mundo'); // 'hello world'
strReplace(['um', 'dois'], 'olá', 'um dois três'); // Output 'olá olá três'
Multiple string replace PHP str_replace clone