Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6371321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:02:57+00:00 2026-05-25T01:02:57+00:00

At work, I was encountering a problem where users of our application were receiving

  • 0

At work, I was encountering a problem where users of our application were receiving messages featuring an invalid unicode character (0xffff), which according to the standard, should never be mapped to a symbol.

As a quick work aound I did the following:

badStr.replace(/\uffff/g, " ");

Which works as expected, and lets the user continue using the application until we find a better solution.

However, while I was playing around with this, I randomly tried a string replacement of “$$$$” which somehow got collapsed “$$”.

You can see for yourself. Try pasting the following lines in your browser url bar:

javascript: alert(String.fromCharCode(0xffff).replace(/\uffff/g, "@@@@"));

results in @@@@

but

javascript: alert(String.fromCharCode(0xffff).replace(/\uffff/g, "$$$$"));

results in $$

This actually seems to be a problem with any string replacement, with $$$$ as the string replacement.

Both:

javascript: alert(String.fromCharCode(0x1234).replace(/\u1234/g, "$$$$"));
javascript: alert("hella".replace("h", "$$$$")); 

result in the $$ collapse.

Any ideas as to why the string replacement behaves this way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:02:58+00:00Added an answer on May 25, 2026 at 1:02 am

    That’s because $ in the replace string has special meaning (group expansion). Have a look at this example:

    alert("foo".replace(/(.*)/, "a$1b"));
    

    That’s why $$ is interpreted as $, for the case where you would need to actually replace something by $1 (literally, without group expansion):

    alert("foo".replace(/(.*)/, "a$$1b"));
    

    See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm encountering a very strange problem: my delete actions in rails don't work anymore.
I am encountering a very strange problem in my wxWidgets application. What I am
I seem to be encountering a very odd problem which only occurs when trying
Work on this small test application to learn threading/locking. I have the following code,
At work we are currently still using JUnit 3 to run our tests. We
I am encountering the following problems trying to work through the quagmire of settings
I´m encountering this problem trying to mock some objects that receive complex lambda expressions
Hello, it's really the first time for me to post. I'am encountering a problem
I have multiple foreach loops through which i am fetching the work history ,
I'm a beginner and this is my first time encountering problem like this. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.