This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Replaceing Characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Replaceing Characters" Watch "Replaceing Characters" New topic
Author

Replaceing Characters

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
How can I use javascript to replace the / in a string?

I have tried myString.replace(///g,"") but it generates an error.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

You need to bone up on regular expression syntax. because the / is used as the delimiter, you cannot just use it straight-away inside the expression. You need to delimit it the same way you would delimit a quote inside a string literal.

Try:


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Replaceing Characters
 
Similar Threads
WA #1.....word association
Cant use object from another class
Posting to bump up my count...
Text box value is not being completely filled with request attribute
The x900 effect ?