/** * This function works just like normal string.repleace but it will catch exceptions/errors and return defult value if provided * @param arg1 Object on witch repleacment will be made * @param arg2 String that will be repleaced * @param arg3 Replacing String * @param arg4 Default value */ export function replace(arg1: string, arg2: string, arg3: string, arg4?: string): string{ var object: string = arg1; try{ object = arg1.toString().replace(arg2, arg3); }catch(exceptions){ if(arg4 != null){ object = arg4; } console.log(exceptions); } return object; }