View Full Version : cutting out between the words

08-01-2006, 09:07 PM
is there a function that would remove character beteen two words?
suppose i had a "hello this is me how are you doing" and i pass me and you i want the string to be "hello this is me you doing"

08-01-2006, 09:11 PM
var textstring = "Hello this is me how are you doing";
var newtextstring = textstring.replace("how are you ","");

08-02-2006, 05:00 AM
no the problem is i don't know what is between me and you so i can only supply those two. some junk characters are being placed in between. i just gave it as example and said i want to pass me and you and get rid of everyting in between that

08-02-2006, 05:19 AM
function removeStr(str, start, end){
var pattern = new RegExp(start + ".*" + end, "gi");
return str.replace(pattern, start + " " + end);

var s = "Hello this is me how are you doing";
alert(removeStr(s, "me", "you"));