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

  • Home
  • SEARCH
  • 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 6054287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:08:10+00:00 2026-05-23T08:08:10+00:00

I have a large piece of HTML/CSS/JS which gets served to 3rd party sites

  • 0

I have a large piece of HTML/CSS/JS which gets served to 3rd party sites via a script tag. The script tag has an id which I use to match and insert the content at the correct location (no nasty document.write). However, I’ve come across a really odd error. Any line with a regex in it seem to escape itself from the string. Below is an example of a problem line (one of a few that are causing problems):

+"        // preceding code"
+"        var remSpc = new RegExp('[\$%,]', 'ig');"
+"        // following code"

The preceding and following lines are correctly escaped, the syntax for the middle line looks correct to me, but it’s throwing an “unexpected end of input” error and WebKit Inspector is showing it as being unescaped. Screen below to show what I mean by unescaped:

enter image description here

The purpose of the regex is to remove special characters from $ amounts and percentages (example values might be “$1,000” or “5.5%”. I’ve tried not using a RegExp object and instead just doing `/[\$%,]/ig and I get exactly the same problem.

N.B the issue is not with this regex in particular, I have a few regexs and every line containing one is behaving the same 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-23T08:08:11+00:00Added an answer on May 23, 2026 at 8:08 am

    A string within a string should be doubly escaped:

    //...
    +"        var remSpc = new RegExp('[\\\\$%,]', 'ig');"
    

    The first \ is to escape the second \.

    Edit: Changed it to \\\\ as per Felix’s comment. We need this because normally it would be:

    /...\$.../
    

    But, the regex is in a string so:

    '...\\$...'
    

    And, then, that string is in another string, intended to be evaluated:

    "...'...\\\\$....'..."
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large piece of text in which there is something simular to
I have a large text file ( data ) which has the following layout:
I'm currently facing a large piece of legacy code which I have to understand
I have a large piece of Python 2 only code. It want to check
I am a beginner in programming. I have a large piece of code. I
I have a large web application. One very small piece of this web application
So we have this tool, it's a web page, we drop a large piece
I have a JavaScript widget (a piece of embedded JS and HTML code) that's
I'm currently developing a large piece of software base on JavaEE. We have followed
I have a large Java EE system connecting to an Oracle database via JDBC

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.