Thursday, 23 June 2011

Replace All Search Sting with New String in JavaScript

function ReplaceAll(Source, stringToFind, stringToReplace) {
    var RetVal = "";
    var TempArr;

    try {
        TempArr = Source.split(stringToFind);
        RetVal = TempArr.join(stringToReplace);
    }
    catch (err) { }

    return RetVal;
}

No comments:

Post a Comment