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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:28:21+00:00 2026-05-28T07:28:21+00:00

I am trying to replace strings in a large amount of data and I

  • 0

I am trying to replace strings in a large amount of data and I was hoping to use regular expression for certain updates that I have to make to the text, I should point out that I am fairly new to regular expressions.

Show here is what I am trying to achieve. Within the text I am converting we have the following data {0} {1} {2}, this has to be converted to a new format so
{0} becomes %{ param0 } , {1} becomes %{ param1 }, {2} becomes %{ param2 }.

There is no limit on what the number could be, so far it has reached 16 and may go up in the future (It should be pointed out that the number is actually a string at this point). This is code I have so far but it only updates the value to {param0}. Also if the text contains more than one instance it only updates the first.

   NewText = Regex.Replace(NewText , @"(?<=\{).*(?=\})", "param$0");

Thanks,
Brendy

  • 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-28T07:28:22+00:00Added an answer on May 28, 2026 at 7:28 am

    You can write:

       NewText = Regex.Replace(NewText , @"\{(0|[1-9]\d*)}", "%{ param$1 }");
    

    Regarding this:

    Also if the text contains more than one instance it only updates the first.

    What’s really happening is that if your string is {0} {1} {2}, then your code will replace the 0} {1} {2 part with param0} {1} {2, giving the end result {param0} {1} {2}. So it looks like it’s only updating the first instance, but really what it’s doing is updating all instances as though they were a single instance. This is because the .* notation swallows as much as it can while still allowing the regex to match.

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

Sidebar

Related Questions

I have been trying to use a C# Regex unsuccessfully to remove certain strings
I am trying to search and replace special characters in strings that I am
I'm trying to obfuscate a large amount of data. I've created a list of
I'm trying to come up with a search/replace expression that will convert from Oracle
I am trying to use regular expressions to do some work on strings but
I am trying to replace strings in a document that enclosed in single quotes,
I have been trying real hard understanding regular expression, Is there any way I
I'm trying to use tpl to serialize structs that contain wchar_t* strings. The code
I'm trying to replace the programs that run from my startup directory with a
I'm trying to replace all link href's in a large string with a different

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.