问题描述:

I've been messing around with string.replace and I noticed something very odd with Webkit and Firebug's javascript consoles.

I can repeat this behavior in a blank browser window. (Look at the first and last lines)

>>> "/literature?page=".replace(/page=/i, "page=2")

"/literature?page="

>>> "/literature?page=".replace("page=", "page=2")

"/literature?page=2"

>>> "/literature?page=".replace(/page=/, "page=2")

"/literature?page=2"

>>> "/literature?page=".replace(/page=/i, "page=2")

"/literature?page=2"

Just so nobody thinks I mistyped something, here are screenshots.

Firebug (3.0.14)

Webkit (Latest nightly as of this post's creation.)

网友答案:

In Google Chrome I get the final result the first time. See the image here.

相关阅读:
Top