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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:19:34+00:00 2026-05-12T15:19:34+00:00

I made an application designed to prepare files for translation using lists of regexes.

  • 0

I made an application designed to prepare files for translation using lists of regexes.

It runs each regex on the file using Regex.Replace. There is also an inspector module which allows the user to see the matches for each regex on the list.

It works well, except when a regex contains a back-reference, Regex.Replace does not replace anything, yet the inspector shows the matches properly (so I know the regex is valid and matches what it should).

sSrcRtf = Regex.Replace(sSrcRtf, sTag, sTaggedTag,
  RegexOptions.Compiled | RegexOptions.Singleline);

sSrcRtf contains the RTF code of the page. sTag contains the regular expression in between parentheses. sTaggedTag contains $1 surrounded by the tag formating code.

To give an example:

sSrcRtf = Regex.Replace("the little dog", "((e).*?\1)", "$1", 
  RegexOptions.Compiled | RegexOptions.Singleline);

doesn’t work. But

sSrcRtf = Regex.Replace("the little dog", "((e).*?e)", "$1", 
  RegexOptions.Compiled | RegexOptions.Singleline);

does. (of course, there is some RTF code around $1)

Any idea why this is?

  • 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-12T15:19:35+00:00Added an answer on May 12, 2026 at 3:19 pm

    You technically have two match groups there, the outer and the inner parentheses. Why don’t you try addressing the inner set as the second capture, e.g.:

    ((e).*?\2)
    

    Your parser probably thinks the outer capture is \1, and it doesn’t make much sense to backreference it from inside itself.

    Also note that your replacement won’t do anything, since you are asking to replace the portion that you match with itself. I’m not sure what your intended behavior is, but if you are trying to extract just the match and discard the rest of the string, you want something like:

    .*((e).*?\2).*
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made application which plays video using DirectX.AudioVideoPlayback.Video class. There are methods Play(), Pause(),
I have made an application (for my self) for feeds reading, using SyndicationFeed ,
I have made an application using Java/Hibernate/MySQL, but whenever I try running it, it
I have an application made by using phonegap 1.5.0 and jquery mobile 1.1.0.... I
I have made an option page for my chrome application. Have designed the form
Made an application which targets .net 4 client. Created an installer using Inno Setup
I made test application in Delphi that beeps morse code using Windows API Beep
I made an application in Java (using the Eclipse IDE) and i refer in
I'm developing an application for the XBox using XNA, with a custom made UI
I made an application in NetBeans and I used the Apache Commons IO jar

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.