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

  • Home
  • SEARCH
  • 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 4077342
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:32:18+00:00 2026-05-20T17:32:18+00:00

I am working with a text where all \ns have been deleted (which merges

  • 0

I am working with a text where all “\n”s have been deleted (which merges two words into one, like “I like bananasAnd this is a new line.And another one.”) What I would like to do now is tell Python to look for combinations of a small letter followed by capital letter/punctuation followed by capital letter and insert a whitespace.

I thought this would be easy with reg. expressions, but it is not – I couldnt find an “insert” function or anything, and the string commands seem not to be helpful either. How do I do this?
Any help would be greatly appreciated, I am despairing over here…

Thanks, patrick

  • 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-20T17:32:18+00:00Added an answer on May 20, 2026 at 5:32 pm

    Try the following:

    re.sub(r"([a-z\.!?])([A-Z])", r"\1 \2", your_string)
    

    For example:

    import re
    lines = "I like bananasAnd this is a new line.And another one."
    print re.sub(r"([a-z\.!?])([A-Z])", r"\1 \2", lines)
    # I like bananas And this is a new line. And another one.
    

    If you want to insert a newline instead of a space, change the replacement to r"\1\n\2".

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

Sidebar

Related Questions

I'm working on a project which stores single images and text files in one
Background I am working on a phonetic converter program which converts english text into
Hi I have been working on a large matrix which displays the results of
I am having difficulties with a program that I have been working on all
I have been working on a web page and would like to load multiple
I have been using the ABTableViewCell to create fast scrolling cells. All is working
I have been trying to do this all day. At the end i managed
I have been working on a template using almost all jquery/javascript. Mostly I am
I have been working on this for a while and cannot seem to figure
i have been working on this layout for quite a while. this is the

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.