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 8069159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:55:54+00:00 2026-06-05T12:55:54+00:00

I have a string that a user can edit at any time, and a

  • 0

I have a string that a user can edit at any time, and a regex that is being conducted on the string, to add it to an xml and then save it but they can add ‘$1’ to the string. I just want the text ‘$1’ to be saved but I have to perform a regular expression on the same string that $1 is in. It replaces the $1 with a character from the regex every time.

How do I find, and replace, the $1 in this string?

Example of what is happening:

string1 = '<item id="1">i have $100</item>'

regexp = new RegExp('<item id="1"([^<]|<[^\/]|<\/[^i]|<\/i[^t]|<\/it[^e]|<\/ite[^m]|<\/item[^>])*<\/item>');

data = '<data><item id="1">i have no money</item><item id="2">i have no money</item></data>'

data = data.replace(regexp, string1);

Results

<data><item id="1">i have >00</item><item id="2">i have no money</item></data>
  • 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-06-05T12:55:56+00:00Added an answer on June 5, 2026 at 12:55 pm

    This should only happen if you have a capturing group in the regex.

    If you don’t want your groups to capture, then place ?: inside the start of the group.

    /foo(?:bar)/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement that a user is allowed only to enter string value
I have a arbitrarily large string of text from the user that needs to
I currently have built a system that checks user IP, browser, and a random-string
I have a search method that takes in a user-entered string, splits it at
I have a script that builds my webpage in one string ($content) and then
I'm trying I have a string that I pass into my function from user
I have about 20 text fields on a form that a user can fill
I have a dictionary of strings that i want the user to be able
I have a string that ends with _[a number] e.g. _1 _12 etc etc.
I have a string that looks like this: 9/1/2009. I want to convert it

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.