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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:09:18+00:00 2026-06-09T20:09:18+00:00

I looked around, but couldn’t find what I was looking for…. Basically I have

  • 0

I looked around, but couldn’t find what I was looking for….

Basically I have a string with lots of asterisks scattered around:

Example: red blue green * hello* pink orange 4pgp42g4jg42 * world* violet black

What I am trying to do is split the string up so I can extract “hello” and “world” and eventually print them out as a list using a for statement. The strings I’m working with are longer and do not necessarily have any set number of slices that I would want to take out.

Could anyone assist me with this please?

Thank you

  • 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-09T20:09:19+00:00Added an answer on June 9, 2026 at 8:09 pm

    Have you ever tried the re module? It uses a syntax called regular expression that allows you to do very complicated matches (see the docs here). In your case, you could try something like this:

    import re
    
    # Store your string
    my_str = 'red blue green * hello* pink orange 4pgp42g4jg42 * world* violet black'
    
    # Find matches
    match = re.findall(r'\*([^\*]*)\*', my_str)
    
    # Print everything
    print match
    
    # Iterate
    for item in match:
        print item
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looked around SO but couldn't find anything useful, so.. I have a Backbone.js contacts
I've already looked around but couldn't find the exact solution/problem I'm having right now.
I've looked around here for similar question but couldn't find any that solved my
I looked around and couldn't find it! Maybe I didn't look hard enough,but this
I've looked around but have yet to find a great solution the the following
I've looked around for this but I couldn't find an answer, and I don't
I've looked around for an answer to this one but couldn't find one. I
I've looked around on SO but I couldn't find any similar question. After opening
I looked around on Google for this, but couldn't find anything. I want to
I've looked around but I couldn't find any answers. Anyway, as the title says

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.