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

The Archive Base Latest Questions

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

This sounds very simple, I know, but for some reason I can’t get all

  • 0

This sounds very simple, I know, but for some reason I can’t get all the results I need

Word in this case is any char but white-space that is separetaed with white-space
for example in the following string: “Hello there stackoverflow.”
the result should be: [‘Hello’,’there’,’stackoverflow.’]

My code:

import re

word_pattern = "^\S*\s|\s\S*\s|\s\S*$"
result = re.findall(word_pattern,text)
print result

but after using this pattern on a string like I’ve shown it only puts the first and the last words in the list and not the words separeted with two spaces

What is the problem with this pattern?

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

    Use the \b boundary test instead:

    r'\b\S+\b'
    

    Result:

    >>> import re
    >>> re.findall(r'\b\S+\b', 'Hello there StackOverflow.')
    ['Hello', 'there', 'StackOverflow']
    

    or not use a regular expression at all and just use .split(); the latter would include the punctiation in a sentence (the regex above did not match the . in the sentence).

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

Sidebar

Related Questions

I know it sounds very simple, and there are questions about this. But none
I know this sounds a little bizarre, but there is a very simple application
I know this sounds like a broad question but I can narrow it down
All right, this one is going to sound very weird and I don't know
Forgive how simple this might sound but I'm stuck and need help. I am
So I know this will sound very simple, because I'm sure it is. I
First of, I apologize if this sounds stupid, but I'm very new to WPF.
I know this question is very similar to this one, but I feel its
I know that some devices headphone ports (maybe all of them? any reference here
So my objective sounds simple, I need to make a db driven multiple choice

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.