...

View Full Version : how do you replace a char in a string



code-in-time
05-29-2012, 07:55 PM
Hi

How do you replace a char in a string?

eg var d = f.replace(char(160), "-");


Thanks

Philip M
05-29-2012, 08:17 PM
Something like this:-


txt = txt.replace(//g,"-");
txt = txt.replace(//g,"-");
txt = txt.replace(//g,"-");
txt = txt.replace(//g,"-");

Or perhaps you mean:-


<script type = "text/javascript">

var tstr = "Hello ltere World";
var bstr = '';

for (i=0; i<tstr.length; i++) {
if (tstr.charCodeAt(i)>127) { // outside ASCII range
bstr += '-'; // change to a hyphen
}
else {
bstr += tstr.charAt(i);
}
}
alert (bstr);


</script>
Quizmaster: In legend, the gryphon has the body of a lion and the head and wings of which bird?
Contestant: A goose



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum