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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:12:55+00:00 2026-05-28T04:12:55+00:00

Although im using c# and the .net lib, im interested in a regex-only solution

  • 0

Although im using c# and the .net lib, im interested in a regex-only solution for some text replacement, and am a bit confused by the final hurdle. (Im using http://gskinner.com/RegExr)

Ive got the string

"Foo {0} Bar {1}"

I can use {[0-9]} to match, but when it comes to replacing, id like to keep the number, i.e. would produce:

"Foo $0$ Bar $1$"

If I had decided I wanted to replace curly braces with dollar symbols (for example).

  • 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-28T04:12:55+00:00Added an answer on May 28, 2026 at 4:12 am

    Replace \{(\d+)\} with $\1$

    The parenthesis in the regex “captures” the enclosed portion and it can be accessed in the replacement string using \1 syntax. So if you have multiple capturing groups, the first one is \1 and second one is \2 etc.

    Some regex flavors follow $1 instead of \1 – in that case you should escape explicit $ symbol as $$ in the replacement string. Also, the \ character itself needs to be escaped as usual in the strings.

    The curly braces are special characters and hence need to be escaped.

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

Sidebar

Related Questions

I am developing an online strategy game using .Net v2. Although the game is
I wrote a site using ASP.NET MVC, and although it is not completely SEO
To start off, I'm using Asp.Net MVC 4, and I've modified my solution to
I am having difficulty in consuming the reCaptcha Web Service using C#/.Net 3.5. Although
Although using SQL FOR XML EXPLICIT is cumbersome, I find myself using it often.
Although using daily in my programming , but never realized about this question :
Although I am using mySQL (for now), I dont want any DB specific SQL.
Using PyCrypto (although I've tried this in ObjC with OpenSSL bindings as well) :
I have just started using jQuery and although following code gets the job done,
Although I know how to build a DOM the long, arduous way using the

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.