// @ts-check
/**
* @param {object} regexp - The RegExp constructor.
* @param {string} str - A String that is to be replaced by subStr.
* @param {string} subStr - The String that replaces the substring specified by the specified regexp or substr parameter.
* @return {string}
*/
function replaceIfFound(regexp, str, subStr) {
return regexp.test(str) ? str.replace(regexp, subStr) : str;
}