PDA

View Full Version : Removing words from strings


Ben Chivers
06-27-2002, 04:42 PM
If I have a string '/html/webpage/template12' and I want to remove the word 'template' from it so the string now becomes '/html/webpage/12', how would I go about achieving this?

Any help would be most appreciated.

Many Regards,
Ben Chivers

Lee Brenner
06-27-2002, 05:01 PM
myString = "/html/webpage/template12";
myRegExp = /template/; //a regular expression
replacementString = "";

result = myString.replace(myRegExp, replacementString);


"result" will equal "/html/webpage/12".

Enjoy!