...

View Full Version : cutting out between the words



angelblade27
08-01-2006, 10:07 PM
is there a function that would remove character beteen two words?
eg
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"

boeing747fp
08-01-2006, 10:11 PM
<script>
var textstring = "Hello this is me how are you doing";
var newtextstring = textstring.replace("how are you ","");
</script>

angelblade27
08-02-2006, 06: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

glenngv
08-02-2006, 06: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"));



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum