Soyez le premier à donner votre avis sur cette source.
Snippet vu 4 774 fois - Téléchargée 17 fois
function str_between(string, from, to, edit){ function validyTest(variable){ if (typeof variable != "undefined") { return true; } else { return false; } } function str_replace(a, b, str) {return str_replace2(str, a, b);} function str_replace2(SRs, SRt, SRu) { SRRi = SRs.indexOf(SRt); SRRr = ''; if (SRRi == -1) return SRs; SRRr += SRs.substring(0,SRRi) + SRu; if ( SRRi + SRt.length < SRs.length) SRRr += str_replace2(SRs.substring(SRRi + SRt.length, SRs.length), SRt, SRu); return SRRr; } function nospace(string){ if(string.indexOf("_")>=0){return str_replace("_", " ", string); }else{return str_replace(" ", "_", string);} } string = nospace(string); to = nospace(to); from = nospace(from); if(validyTest(to)==true){ position1 = string.indexOf(from); position2 = string.indexOf(to); content = str_replace(from, "", string.substring(position1, position2)); content = str_replace(to, "", content); }else{ position1 = string.indexOf(from); position2 = string.length; content = str_replace(from, "", string.substring(position1, position2)); content = str_replace(to, "", content); } if(validyTest(edit)){ return nospace(str_replace(content, edit, string)); }else{ return nospace(content); } }
8 avril 2013 à 18:51
8 avril 2013 à 13:01
Merci pour ce script.
Tu n'aurai pas oublié de mettre la fonction nospace() ?
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.