par oguruma » 02 Nov 2006 à 18:48
[syntax="javascript"]function replaceSubstring(inputString, badString, goodString, caseSensitive){
fixedReplace = "";
UI = inputString;
UB = badString;
if (caseSensitive !== 1 && caseSensitive !== true) {
UI = inputString.toUpperCase();
UB = badString.toUpperCase();
}
badEnd = -1;
badLoc = UI.indexOf(UB);
if (badLoc < 0) {
for (x = 1; (badLoc != -1); x++) {
fixedReplace = fixedReplace + inputString.substring((badEnd + 1), badLoc) + goodString;
badEnd = badLoc + UB.length - 1;
badLoc = UI.indexOf(UB, (badLoc + 1));
}
fixedReplace = fixedReplace + inputString.substring((badEnd + 1), inputString.length);
}
else {
fixedReplace = inputString;
}
return fixedReplace;
}[/syntax]
Bien à vous
http://www.dominoarea.org/oguruma/
Les téléphones PORTABLES dans les TGV y en a MARRRE de ces voyageurs qui ne respectent pas les autres ! ARRET DES PORTABLES SVP - Merci
Fumeurs ! respectez les non fumeurs !!!
Fumeurs ! respectez la loi de février 2007 et les lieux publics !!! (ie. hall de gares)