Web Analytics Made Easy -
StatCounter Removing words from strings - CodingForum

Announcement

Collapse
No announcement yet.

Removing words from strings

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Removing words from strings

    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

  • #2
    Code:
    myString = "/html/webpage/template12";
    myRegExp = /template/;   //a regular expression
    replacementString = "";
    
    result = myString.replace(myRegExp, replacementString);
    "result" will equal "/html/webpage/12".

    Enjoy!
    Last edited by Lee Brenner; Jun 27, 2002, 12:03 PM.

    Comment

    Working...
    X