Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace issues

Status
Not open for further replies.

TheConeHead

Programmer
Joined
Aug 14, 2002
Messages
2,106
Location
US
I need to take a / out of a string and tried:

Code:
ipStrip = ipStrip.replace(/\//g,"");

but it does not work...

[conehead]
 
It worked for me in this simple test:
Code:
<html>
<head>
<title>test</title>
<script>
function foo()
{
  var st = "I have / slash";
  alert(st);
  st = st.replace(/\//g,"");
  alert(st);
}
</script>
</head>
<body>
<input type=button onClick="foo();" value=Test>
</body>
</html>
 
It also works fine for me when typing this in the address bar of my browser:

Code:
javascript:var ipStrip = 'wibble/abc/d/ef/g'; ipStrip = ipStrip.replace(/\//g,""); alert(ipStrip);

Maybe there is an error somewhere else in your code?

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top