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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:56:54+00:00 2026-06-04T20:56:54+00:00

I am trying to Parse the following string: EDITED to account for spaces… [‘THE

  • 0

I am trying to Parse the following string:

EDITED to account for spaces…

['THE LOCATION', 'THE NAME', 'THE JOB', 'THE AREA')]

Right now I use regular expressions and split the data with the comma into a list

InfoL = re.split(“,”, Info)

However my output is

'THE LOCATION'
'THE NAME'
'THE JOB'
'THE AREA')]

Looking to have the output as follows

THE LOCATION
THE NAME
THE JOB
THE AREA

Thoughts?

  • 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-04T20:56:55+00:00Added an answer on June 4, 2026 at 8:56 pm

    One possibility is to use strip() to remove the unwanted characters:

    In [18]: s="['LOCATION', 'NAME', 'JOB', 'AREA')]"
    
    In [19]: print '\n'.join(tok.strip("[]()' ") for tok in s.split(','))
    LOCATION
    NAME
    JOB
    AREA
    

    Like your original solution, this will break if any of strings are allowed to contain commas.

    P.S. If that closing parenthesis in your example is a typo, you might be able to use ast.literal_eval():

    In [22]: print '\n'.join(ast.literal_eval(s))
    LOCATION
    NAME
    JOB
    AREA
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to parse the following JSON string remotely: [{name:Object1,data:[1,2]},{name:Object2,data:[3,4]}] I am doing
I am trying to parse the following message string: Row 1> testdata1 |Row 5>
I trying to parse this string: $right = '34601)S(1,6)[2] - 34601)(11)[2] + 34601)(3)[2,4]'; with
I am trying to parse following string... IN.Tags.Share({count:180,url:http://domain.org} is my following approach correct to
I am trying to parse the following string to JSON object.It is giving me
I am trying to parse the following string and get the result. string test
I'm trying to parse the following JSON string returned by httpResponse : { message
I'm working to parse the following string but at the same time trying to
I'm trying to parse a string similar to the following using a spirit parser:
I'm just trying to parse a simple JSON string in the following format: [X,Y,Z]

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.