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

  • Home
  • SEARCH
  • 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 668973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:06:00+00:00 2026-05-14T00:06:00+00:00

This question falls into the yes – this works, yes – this is ugly,

  • 0

This question falls into the “yes – this works, yes – this is ugly, yes – there is probably a better way” category. I want to use a regular expression to pull groups out of a match and then print the group number and the group value. It is to show someone how regular expressions work and to keep track of the values of each group. The code that works is:

import re

FundTypeGroups = re.match("([A-Z]0)(\d)([A-Z])","G02A").groups()
print FundTypeGroups

for FundTypeGroup in FundTypeGroups:
    print "%s: %s" % (FundTypeGroups.index(FundTypeGroup), FundTypeGroup)

Is there a better way to print the index of each tuple entry?

  • 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-14T00:06:00+00:00Added an answer on May 14, 2026 at 12:06 am
     for index, group in enumerate(FundTypeGroups):
         print "%s: %s" % (index, group)
    

    (and the variables should not start with a capital letter…)

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

Sidebar

Related Questions

This question more falls into the category of best practices, and clean/safe code for
My question falls into the category what's the best way to? how would you
I concede that this question may fall into the 'discussable' but not 'answerable' category.
This question is probably best suited towards anyone with some insight into disk read
In this question , it was suggested to use Console.in.read.toChar . It works fine
Warm Standby SQL Server/Web Server This question might fall into the IT category but
I hope this doesn't fall into the non question category. I would like to
My guess is that this question will fall under the category of duh, but,
This is more of a conceptual question. If it helps, lets say it falls
This question is quite simple but I have run into the problem a few

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.