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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:40:34+00:00 2026-05-26T18:40:34+00:00

I am trying to parse some C# code to Python. There are several regular

  • 0

I am trying to parse some C# code to Python. There are several regular expression in that code. Everything worked fine so far, but now I’ve got the following problem:

C# Code:

Match m = regEx.Match( Expression );
while( m.Success )
{
    Expression = Expression.Replace( m.Value, m.Groups[1].Value + this.Solve( m.Groups[2].Value ) );
}

What can I do to make this code working in python? I’ve already tried something like this:

matchObj = re.search(pattern = p, string = expression, flags = re.IGNORECASE)
while matchObj:
    if len(matchObj.group(3)) > 0:
        expression = re.sub(pattern = p, repl = matchObj.group(1) + self.solve(matchObj.group(2)), string = matchObj.string, flags = re.IGNORECASE) #Here is the problem...

So actually I am looking for something equivalent of matchObject.Value.

Thank you for your help.

  • 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-26T18:40:35+00:00Added an answer on May 26, 2026 at 6:40 pm

    I think this is what you are trying to do; match.group() (without a parameter) returns the match the whole regex matches:

    m = re.search( pattern, text )
    if m and len( m.group(3) ) > 3:
        text = text.replace( m.group(), m.group(1) + solve( m.group(2) ) )
    

    I’m not sure why you had a loop there, so I removed it. Another way, without using str.replace would be to manipulate the string based on the positions returned by m.start() and m.end().

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

Sidebar

Related Questions

I'm trying to test some python code that uses urllib2 and lxml. I've seen
I'm trying to parse some poorly generated xml code with scala that looks like
I'm trying to parse a html doc using some code I found from this
Trying to parse some XML but apparently this is too much for a lazy
I have some HTML I am trying to parse. There are cases where the
I am trying to parse some data and just started reading up on regular
I'm trying to parse some HTML using DOMDocument, but when I do, I suddenly
I'm trying to translate some python code to haskell. However I reached a point
I am just trying to write a small web page that can parse some
I am trying to write a program to check that some C source code

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.