lib/replace.js
function runModule(module, str, replacements) {
    var pattern = module.pattern,
        replace = module.replace,
        match;

    // Reset the pattern so we can re-use it
    pattern.lastIndex = 0;

    while ((match = pattern.exec(str)) !== null) {
        replacements[match.index] = {
            oldStr: match[0],
            newStr: typeof replace === "function"? replace(match) : replace
        };
        if (pattern.global === false) {
            // if the search isn't global we need to break manually
            // because pattern.exec() will always return something
            break;
        }
    }
}
function runModule(module, str, replacements) {
    var pattern = module.pattern,
        replace = module.replace,
        match;

    // Reset the pattern so we can re-use it
    pattern.lastIndex = 0;

    while ((match = pattern.exec(str)) !== null) {
        replacements[match.index] = {
            oldStr: match[0],
            newStr: typeof replace === "function"? replace(match) : replace
        };
        if (pattern.global === false) {
            // if the search isn't global we need to break manually
            // because pattern.exec() will always return something
            break;
        }
    }
}
function runModule ( module , str , replacements ) { var pattern = module . pattern , replace = module . replace , match ; // Reset the pattern so we can re-use it pattern . lastIndex = 0 ; while ( ( match = pattern . exec ( str ) ) !== null ) { replacements [ match . index ] = { oldStr : match [ 0 ] , newStr : typeof replace === "function" ? replace ( match ) : replace } ; if ( pattern . global === false ) { // if the search isn't global we need to break manually // because pattern.exec() will always return something break ; } } }
Matches the module's pattern against the string and stores the scheduled replacement
under the corresponding array index.

@private
@param {ReplacementModule} module
@param {String} str
@param {Array<Replacement>} replacements
Matches the module s pattern against the string and stores the scheduled replacement under the corresponding array index .