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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:36:12+00:00 2026-05-30T07:36:12+00:00

IDLE 1.1.4 >>> import re >>> some_text = ‘alpha, beta,,,,gamma delta’ >>> re.split(‘[, ]+’,

  • 0
IDLE 1.1.4      
>>> import re
>>> some_text = 'alpha, beta,,,,gamma   delta'
>>> re.split('[, ]+', some_text)
['alpha', 'beta', 'gamma', 'delta']
# when the pattern doesn't contain parentheses, the returned values 
# only include matched substrings but separators.

>>> re.split('([, ]+)', some_text)
['alpha', ', ', 'beta', ',,,,', 'gamma', '   ', 'delta']
# returned values include separators and I can guess how it works.

>>> re.split('([, ])+', some_text)
['alpha', ' ', 'beta', ',', 'gamma', ' ', 'delta']
# Now I cannot even guess what is going on here.

Question> What is the difference between '([, ]+)' and '([, ])+'?
How it affects the returned values?

  • 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-30T07:36:14+00:00Added an answer on May 30, 2026 at 7:36 am

    ([, ]+) says “match one or more commas and/or spaces and capture them as a group”, thus in your second example your see the whole string of separator characaters returned in one group.

    ([, ])+ says “match one comma or space, and capture one or more groups of these”. So in your third example, each separator character is captured in it’s own group, and you’re only getting the last of these each time.

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

Sidebar

Related Questions

when I type the following on python2.5 IDLE (windows vista 32-bit)-- from pywinauto import
If I import a module in IDLE using: import <module_name> print <module_name>.__file__ how can
IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall
An idle question on language design, see Does C# have a right hand if
Python's IDLE has 'Check Module' (Alt-X) to check the syntax which can be called
Why does IDLE handle one symbol correctly but not another? >>> e = '€'
I messed up my IDLE shortcut. What is the way to start IDLE from
This happens in IDLE and Windows 7 RC1 (if that helps). Here is the
I love the IDLE. However, sometimes I have 100-200 line scripts and I want
I wrote an an idle hook shown here void vApplicationIdleHook( void ) { asm(nop);

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.