472,119 Members | 1,675 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Replace method of String object doesn't work

It looks like the String.replace doesn't work in IE6.1. Anyone else
has the same problem. I am using newest service package of IE and
Win2K.

Thanks
Jul 20 '05 #1
1 16189
Thomas wrote:
It looks like the String.replace doesn't work in IE6.1. Anyone else
has the same problem. I am using newest service package of IE and
Win2K.

Thanks


There are a number of issues going on here.

One, there is no such thing as IE 6.1, the latest version of IE is 6.0
Service Pack 1.

Two, just because you are running IE 6.0SP1 does not guarantee that you
are running JScript 5.6, the way to verify this is to go to:

Start -> Run -> type "cmd", hit Enter
type "cscript", hit Enter
You should see something similar to "Microsoft (R) Windows Script Host
Version 5.6", the number you see there is the version of JScript you are
using. If it's anything other then 5.6, check <url:
http://msdn.microsoft.com/library/en...nformation.asp
/> to see if String.replace() is a supported method for your version of
JScript (hint: replace() has been a method of the String object since
JScript 1.0).

Three, alert("My String".replace(/String$/, "New String")); works just
fine.

Four, note that String objects are immutable, that is, you don't modify
the original String when you call replace(), but instead a new String
object is returned that contains the replaced String.

var s = "My String";
s.replace(/String$/, "New String");
alert(s);
// alerts "My String"

var s = "My String";
s = s.replace(/String$/, "New String");
alert(s);
// alerts "My New String"

In the future, instead of simply stating that some method doesn't work,
perhaps you could include the simplest example of your code that
exhibits the incorrect behaviour. Often the very act of simplifying your
code to demostrate the problem reveals the cause of the problem.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by gipsy boy | last post: by
3 posts views Thread by Steph. | last post: by
reply views Thread by m m via DotNetMonster.com | last post: by
2 posts views Thread by Peter Afonin | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.