simple find and replace string





8
Date Submitted Thu. Aug. 10th, 2006 2:41 AM
Revision 1 of 1
Syntax Master sundaramkumar
Tags JavaScript
Comments 1 comments
simple find and replace string


function SrchReplace(Text, Search, Replace) {
        while (Text.indexOf(Search)>=0) {
                var i = Text.indexOf(Search);
                Text = Text.substr(0, i)+Replace+Text.substr(i+Search.length);
        }
        return Text;
}


 
If parameter Replace is equal to "" the function simplly removes substring Search from Text string.

Comments

Comments Aargh! Meant to vote up!
Fri. Sep. 22nd, 2006 7:11 AM    Scripter sehrgut

Voting