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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:54:19+00:00 2026-06-12T04:54:19+00:00

so I have a quick question that I cannot figure out. I have some

  • 0

so I have a quick question that I cannot figure out.

I have some lines that I want to parse for example:

  • a = a/2;
  • b*= a/4*2;
  • float c += 4*2*sin(2);

And what I want is to get the assigned variable name of the assignment. So, in this case I woule like to retrieve a, b, c.

I have the following regex:

match = re.search(r'\b(?:float)?(.*)(?:(\+|-|\*|\\)? =)',line)

When I print out m.group(1) it would return a, b *, c +.

I cannot figure out why it also captures the operator before =, could someone explain?

  • 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-12T04:54:20+00:00Added an answer on June 12, 2026 at 4:54 am

    You have a preceding greedy capture with the (.*) and you’re allowing your operator-capture to be optional (with the ending ?); With this, the greedy-capture is the one that’s bringing in the operator instead of letting it fall-through to the group matching the =.

    Try changing the greedy-capture to be only what is acceptable there. From the looks of it, it could only be alpha-numeric values and spaces (numeric is a guess, so that could be dropped if not needed):

    \b(?:float\s+)?([a-zA-Z0-9]+)\s*(?:(\+|-|\*|\\)? =)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a quick question that I can't figure out. I've tried searching Google
Quick question about include/requre_once . I have some code that is common to a
A quick technical question- I have two queries that output some of the same
I have a quick question that I'm sure some of you would have an
Just a quick question, that I cannot fathom out, hope you guys and girls
quick question, I have some markdown HTML content that I'd like to convert from
I have a quick question that I can't seem to find online. I am
I have a quick question here. I know that the cakePHP find('first') function returns
I have a question that should be quick and easy for you guys to
just a question that needs a quick answer, I have a Action, lets say,

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.