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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:15:42+00:00 2026-06-14T19:15:42+00:00

I have a string in this format: any_string = [u’02’, u’03’, u’04’, u’05’] .

  • 0

I have a string in this format: any_string = "[u'02', u'03', u'04', u'05']".
I want to extract a list from this which should look like new_list = ['02', '03', '04', '05']

I am using ‘re’. The below code i am writing to get this work done, but no luck

import re

new_list = re.findall(r'["w "]', any_string)

I am getting the result as [' ', ' ', ' ']

Basically I want a list like this new_list = ['02', '03', '04', '05'], so that i can loop through the individual items like 02, 03, 04 , 05

  • 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-14T19:15:43+00:00Added an answer on June 14, 2026 at 7:15 pm

    If you aren’t tied to re, what about ast? Just one more letter 🙂

    In [1]: import ast
    
    In [2]: any_string = "[u'02', u'03', u'04', u'05']"
    
    In [3]: my_list = ast.literal_eval(any_string)
    
    In [4]: type(my_list)
    Out[4]: <type 'list'>
    
    In [5]: my_list
    Out[5]: [u'02', u'03', u'04', u'05']
    
    In [6]: for item in my_list:
       ...:     print item
       ...:
       ...:
    02
    03
    04
    05
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string like 123-123-1234 so I want to convert string into this format
I have a string in XML format and I want to use this string
I have a date in String format, mm/dd/yyyy I want to convert this to
I have this code: con.Open(); cmd = new MySqlCommand(String.Format(SELECT concat(name,'|',lastname) FROM {0} WHERE ID=
I have a date in this string format 02/28/2012 and I want to convert
I have a string of this format /abcd-efg-sms-3-topper-2 I want to remove the first
I have a string date like this: $date = 23/12/2011;//format: dd/mm/yyyy. I need each
I have a string with a date which is in this format MMDDYYYY (ie.
I have a date string, returned from a ExtJS datetime picker, which looks like
I have a string of this format 1.0.x.0 I have to write a regex

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.